我正在尝试使用为FFMPEG制作的NReco.VideoConverter包装类来连接视频。
我有三个具有相同帧速率和相同帧大小的视频文件。
这就是我所做的。
string toconcatfile = @"C:\Users\Alan\Desktop\Black.mp4";
string output1 = @"C:\Users\Alan\Desktop\output1.mp4";
string output2 = @"C:\Users\Alan\Desktop\output2.mp4";
string finaloutput = @"C:\Users\Alan\Desktop\finaloutput.mp4";
当我将toconcatfile添加到最终转换方法时,所有三个视频的帧速率都为25,视频帧大小却失败了。
当它只是output1和output2意味着toconcatfile中必须有不同的设置时,它才有效。
这是我尝试过的。
FFMpegConverter fFMpeg = new FFMpegConverter();
//Slices first video
ConvertSettings settings = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
MaxDuration = startcut,
AudioSampleRate = 44100
};
//Slices second video
ConvertSettings settings2 = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
Seek = endcut,
AudioSampleRate = 44100
};
//Copies framerate and size from the previous video to the concatenation video
ConvertSettings settings3 = new ConvertSettings
{
VideoFrameRate = 25,
VideoFrameSize = FrameSize.hd480,
MaxDuration = 4,
AppendSilentAudioStream = true,
AudioSampleRate = 44100
};
string newblack = @"C:\Users\Alan\Desktop\newblack.mp4";
//Slice method called
fFMpeg.ConvertMedia(pathtofile, Format.mp4, output1, Format.mp4, settings);
fFMpeg.ConvertMedia(pathtofile, Format.mp4, output2, Format.mp4, settings2);
fFMpeg.ConvertMedia(toconcatfile, Format.mp4, newblack, Format.mp4, settings3);
String[] inputfiles = new String[2];
inputfiles[0] = output1;
inputfiles[1] = newblack;
//inputfiles[1] = output2;
ConcatSettings concatSettings = new ConcatSettings
{
//CustomOutputArgs = output1+" "+ toconcatfile+ " "+output2+ " -filter_complex \"[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]\" -map \"[outv]\" - map \"[outa]\""
};
fFMpeg.ConcatMedia(inputfiles, finaloutput, Format.mp4, concatSettings);
有人可以帮忙吗?
编辑:我收到异常消息 - “无效参数(退出代码:1)”,
这是FFMPEG的输出日志
FFMPEG LOG ITEM - ffmpeg version 3.2.2 Copyright (c) 2000-2016 the
FFmpeg developers
FFMPEG LOG ITEM - built with gcc 5.4.0 (GCC)
FFMPEG LOG ITEM - configuration: --enable-gpl --enable-version3 --enable-
dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --
enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
FFMPEG LOG ITEM - libavutil 55. 34.100 / 55. 34.100
FFMPEG LOG ITEM - libavcodec 57. 64.101 / 57. 64.101
FFMPEG LOG ITEM - libavformat 57. 56.100 / 57. 56.100
FFMPEG LOG ITEM - libavdevice 57. 1.100 / 57. 1.100
FFMPEG LOG ITEM - libavfilter 6. 65.100 / 6. 65.100
FFMPEG LOG ITEM - libswscale 4. 2.100 / 4. 2.100
FFMPEG LOG ITEM - libswresample 2. 3.100 / 2. 3.100
FFMPEG LOG ITEM - libpostproc 54. 1.100 / 54. 1.100
FFMPEG LOG ITEM - Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\output1.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:00:30.02, start: 0.000000, bitrate: 543 kb/s
FFMPEG LOG ITEM - Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 3893:2872 DAR 276403:114880], 407 kb/s, SAR 12800:9443 DAR 320:133, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\newblack.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:00:04.02, start: 0.000000, bitrate: 19 kb/s
FFMPEG LOG ITEM - Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 160:213 DAR 4:3], 7 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Alan\Desktop\output2.mp4':
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - major_brand : isom
FFMPEG LOG ITEM - minor_version : 512
FFMPEG LOG ITEM - compatible_brands: isomiso2avc1mp41
FFMPEG LOG ITEM - encoder : Lavf57.56.100
FFMPEG LOG ITEM - Duration: 00:01:34.22, start: 0.000000, bitrate: 1058 kb/s
FFMPEG LOG ITEM - Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480 [SAR 3893:2872 DAR 276403:114880], 923 kb/s, SAR 12800:9443 DAR 320:133, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
FFMPEG LOG ITEM - Metadata:
Exception thrown: 'NReco.VideoConverter.FFMpegException' in NReco.VideoConverter.dll
FFMPEG LOG ITEM - handler_name : VideoHandler
FFMPEG LOG ITEM - Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
FFMPEG LOG ITEM - Metadata:
FFMPEG LOG ITEM - handler_name : SoundHandler
FFMPEG LOG ITEM - [Parsed_concat_0 @ 04ded5e0] Input link in1:v0 parameters (size 852x480, SAR 160:213) do not match the corresponding output link in0:v0 parameters (852x480, SAR 12800:9443)
FFMPEG LOG ITEM - [Parsed_concat_0 @ 04ded5e0] Failed to configure output pad on Parsed_concat_0
FFMPEG LOG ITEM - Error configuring complex filters.
FFMPEG LOG ITEM - Invalid argument