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

merge two mp4 video as single video using ffmpeg in C# is not working

在过去的 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 文件中的视频路径是 wrong.So,使其正确并且可以完全工作。但是有些视频需要太多时间,有些视频工作得更快。不知道是什么原因。

谢谢大家