You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ScreenRecorderLib录制的MP4文件无法播放及录制异常问题求助

ScreenRecorderLib录制的MP4文件无法播放及录制异常问题求助

各位好,我在使用ScreenRecorderLib时碰到了几个棘手的问题,折腾好一阵都没解决,想过来请教大家:

遇到的核心问题

  1. 生成的MP4文件无法播放:录制完成后,系统提示「This file isn't playable. That might be because the file type is unsupported, the file extension is incorrect, or the file is corrupt.」,我特意安装了VLC播放器尝试,同样无法打开该文件。
  2. 录制行为异常:
    • 必须手动删除已存在的test.mp4文件,才能正常触发录制(否则目标文件大小完全不会变化);
    • 录制4-5秒的视频,最终文件仅1.5MB左右,尺寸明显偏小。

我的环境与已执行操作

  • 系统:Windows 10 Pro(根据说明未安装Media Feature Pack,因为Pro版应该自带相关组件)
  • 已按库的官方要求安装x64版本的Visual C++ Redistributable
  • 开发环境:VS2022控制台项目,已导入ScreenRecorderLib的NuGet包,项目平台已从「Any CPU」切换为「x64」

我使用的代码

using ScreenRecorderLib;
using System.IO;

Recorder _rec;

void CreateRecording()
{
    _rec = Recorder.CreateRecorder();
    _rec.OnRecordingComplete += Rec_OnRecordingComplete;
    _rec.OnRecordingFailed += Rec_OnRecordingFailed;
    _rec.OnStatusChanged += Rec_OnStatusChanged;

    string videoPath = Path.Combine(Path.GetTempPath(), "test.mp4");
    Console.WriteLine("VideoPath: " + videoPath);
    _rec.Record(videoPath);
}

void EndRecording()
{
    _rec.Stop();
}

void Rec_OnRecordingComplete(object sender, RecordingCompleteEventArgs e)
{
    string path = e.FilePath;
}

void Rec_OnRecordingFailed(object sender, RecordingFailedEventArgs e)
{
    string error = e.Error;
}

void Rec_OnStatusChanged(object sender, RecordingStatusEventArgs e)
{
    RecorderStatus status = e.Status;
}

Console.WriteLine("Hello, World!");
CreateRecording();
Console.ReadLine();
EndRecording();

补充说明

录制过程中我能看到目标文件大小在缓慢增长,VS的资源占用也有明显飙升,说明录制动作确实在执行,但最终生成的文件就是存在异常。有没有朋友遇到过类似情况,或者能帮我排查下代码或配置哪里出了问题吗?


内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 12:58:02