c# - 在 C# 中使用 ffmpeg.exe 将 MPG 转换为 AVI

标签 c# video ffmpeg

我在将 MPG 文件转换为 AVI 文件时遇到问题。当我转换一个文件时,例如 520KB MPG 文件,我的程序生成了一个大约 112MB 的 AVI 文件并且该视频无法正常工作。什么会导致这种情况?

     string path = "C:\\convert\\input.mpg" 
     string outputpath = "C:\\convert\\"+output+".avi";

     string fileargs = "-i" + " " + path + "  " + outputpath;


        System.Diagnostics.Process p = new System.Diagnostics.Process();
        p.StartInfo.FileName = "C:\\convert\\ffmpeg.exe";
        p.StartInfo.Arguments = fileargs;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();


        p.WaitForExit();

最佳答案

我已将其用于 Quicktime 重新包装。不确定它在 AVI 上是否也能正常工作,但您可以试一试。

fileargs = String.Format("-i {0} -vcodec copy -acodec copy {1}", path, outputpath);

或者,如果这不起作用,您可以尝试:

fileargs = String.Format("-i {0} -vcodec copy -acodec pcm_s16le {1}", path, outputpath);

关于c# - 在 C# 中使用 ffmpeg.exe 将 MPG 转换为 AVI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4257344/

相关文章:

c# - 如何在 Web Api 中发布自定义命名方法?

c# - 更改 HttpClient 的基址

c# - .NET Core 中的 System.Attribute.GetCustomAttribute

c# - 如何克服 PathTooLongException?

android - 如何在android中播放mp4视频

c++ - av_read_frame() 方法的输入参数

video - 有没有办法在嵌入的youtube或vimeo(或其他)视频上强制HD(720p)?

javascript - 通过绑定(bind)到 div 的 onclick 事件在 iPad 上加载 HTML5 视频

FFMPEG CLI 语言元数据标记输出 MP4(视频 + 音频)文件

android - FFmpeg 中的 amix 过滤器失败,具体取决于 mp3 输入