gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:03:25 31 4
gpt4 key购买 nike

在过去的 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com