gpt4 book ai didi

c# - FFMPEG NReco.ConcatMedia 合并来自不同来源的文件

转载 作者:行者123 更新时间:2023-12-04 23:26:40 49 4
gpt4 key购买 nike

需要帮助解决后续问题。
我从 youtube 下载了 3 个视频,并使用 NReco.VideoConverter.FFMpegConverter.ConvertMedia 将其剪切成小块,并使用以下代码:

        ffMpegConverter.ConvertMedia (SourceFile, Format.mp4, tempVideo, Format.mp4,
new ConvertSettings () {
Seek = StartTime,
MaxDuration = (EndTime - StartTime),
VideoCodec = "libx264",
AudioCodec = "mp3",
CustomOutputArgs = string.Format ("-vf \"pad=640:360:x=(640-iw)/2:y=(360-ih)/2:color=black\" -af \"volume = {0}dB\"", volumeMultiplier),
VideoFrameRate = 25,
AudioSampleRate = 44100,
VideoFrameSize = "640x360"
});

并添加水印(仅使用内联 ffmpeg 命令):
-i {0} -i {1} -filter_complex \"[1:v]scale={3}:{4},format=argb,colorchannelmixer=aa={5}[wat];[0:v][wat]overlay=main_w-overlay_w-{6}:main_h-overlay_h-{7} [out]\" -map \"[out]\" -map 0:a -y {2}

当我从源 #1 和 #2 连接视频片段时,没关系,但对于 #3 则不行。我相信 (#1, #2) 和 (#3) 格式之间存在某种兼容性问题,但这应该在 ConvertMedia 阶段解决,不是吗?可能是我错过了一些 OutPut 参数吗?

来自源 #3 https://jpst.it/Zoof 的文件的示例 MediaInfo

还有一个来自源 #2 https://jpst.it/ZooC 的文件

为什么无法加入文件,在哪里搜索原因?

谢谢。

最佳答案

我没有找到 NReco 没有合并这些文件的原因,但我编写了自己的包装器

     static void Main (string[] args) {
concatMedia (new string[] {
args[0], args[1]
}, args[2]);
}

private static string makeTempFile (string fileName) {
FFMpegConverter c = new FFMpegConverter ();
FileInfo fileInfo = new System.IO.FileInfo (fileName);
string tempFile = Path.Combine (fileInfo.DirectoryName, Path.GetFileNameWithoutExtension (fileName) + ".ts");
c.Invoke (string.Format ("-i {0} -c copy -bsf:v h264_mp4toannexb -f mpegts -y {1}", fileName, tempFile));
return tempFile;
}

private static void concatMedia (string[] files, string output) {
FFMpegConverter c = new FFMpegConverter ();
List<string> tempFiles = new List<string> ();
foreach (var item in files) {
tempFiles.Add (makeTempFile (item));
}
c.Invoke (string.Format ("-i \"concat:{0}\" -c copy -bsf:a aac_adtstoasc -y {1}", string.Join ("|", tempFiles), output));
foreach (var item in tempFiles) {
System.IO.File.Delete (item);
}
}

关于c# - FFMPEG NReco.ConcatMedia 合并来自不同来源的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43891341/

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