c# - 在 C# 中使用 ffmpeg 将两个 mp4 视频合并为单个视频不起作用

标签 c# ffmpeg video-streaming

在过去的 4 个小时里,我一直在尝试使用 C# 中的 ffmpeg 将 2 个 .mp4 文件合并为一个。

****我的代码如下:****

   public void MergeFiles(string strFile)
    {
        string strParam;

        string Path_FFMPEG = Server.MapPath("~/Video_Clips/ffmpeg.exe");

        //Merging two videos               
        String video1 = Server.MapPath("~/Videos/fast1.mp4");
        String video2 = Server.MapPath("~/Videos/fast2.mp4");
        String file = Server.MapPath("~/Videos/input.txt");
        String strResult =   Server.MapPath("~/Videos/ConvertedFiles/Output.mp4");

        strParam = " -f concat -i " + file + " -c copy " + strResult;

        process(Path_FFMPEG, strParam);
    }

   public void process(string Path_FFMPEG, string strParam)
    {
        try
        {
            Process ffmpeg = new Process();
            ProcessStartInfo ffmpeg_StartInfo = new ProcessStartInfo(Path_FFMPEG, strParam);
            ffmpeg_StartInfo.UseShellExecute = false;
            ffmpeg_StartInfo.RedirectStandardError = true;
            ffmpeg_StartInfo.RedirectStandardOutput = true;
            ffmpeg.StartInfo = ffmpeg_StartInfo;
            ffmpeg_StartInfo.CreateNoWindow = true;
            ffmpeg.EnableRaisingEvents = true;
            ffmpeg.Start();
            ffmpeg.WaitForExit(30000);
            //ffmpeg.WaitForExit();
            ffmpeg.Close();
            ffmpeg.Dispose();
            ffmpeg = null;
        }
        catch (Exception ex)
        {

        }
    }

我的 input.txt 文件如下:

要加入的文件列表(评论)

文件“D:/Kapil_WorkSpace/ExtraProjectSource/VideoDemo/VideoDemo/Videos/fast1.mp4”

文件“D:/Kapil_WorkSpace/ExtraProjectSource/VideoDemo/VideoDemo/Videos/fast2.mp4”

请帮忙。提前致谢。

最佳答案

最后,我找到了我自己问题的答案。

我使用了 ffmpeg.exe 文件,并且有 32 位系统,我使用的是 64 位。
所以,问题出在 ffmpeg 构建文件中。我为此下载了新的 64 位版本。

另一个问题是 input.txt 文件中的视频路径是错误的。所以,让它正确并且完全可以工作。但是有些视频需要太多时间,有些视频工作得更快。我不知道这是什么原因。

谢谢大家

关于c# - 在 C# 中使用 ffmpeg 将两个 mp4 视频合并为单个视频不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35356155/

相关文章:

c# - 有条件地更新数据表中数据的最快方法是什么?

c# - Visual Studio 测试项目基目录

c# - 如何使具有相同数据的对象具有相同的键?

flash - 没有adobe cirrus的点对点连接

asp.net - Stream.WriteAsync 抛出远程主机关闭连接异常

c# - Thread.CurrentPrincipal 在 Azure 上具有空详细信息

FFmpeg 在浏览器上播放音频流

multithreading - FFmpeg 中用于最快转换为 h264 的线程计数选项?

ffmpeg:如何在 m3u8 播放列表中包含动态路径? (播放列表和片段位于不同的目录中。)

tcp - 确定 RTSP 服务器是否正在运行并需要身份验证