我正在尝试将多个视频合并成一个视频。从下面ffprobe
4 个示例视频的输出可以看出,它们在某些方面都有所不同。
理想情况下,我希望将每个尺寸标准化为某个特定的尺寸 - 比如 1280x720 - 然后将它们连接起来。
我一直在尝试类似这样的变化:
ffmpeg -hide_banner -loglevel error -i ./tmp/1.mp4 -i ./tmp/2.mp4 -i ./tmp/3.mp4 -i ./tmp/4.mp4
-filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[var0];
[1:v]scale=1280:720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[var1];
[2:v]scale=1280:720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[var2];
[3:v]scale=1280:720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[var3];[var0][0:a:0][var1][1:a:0][var2][2:a:0][var3][3:a:0]concat=n=4:v=1:a=1[v][a]"
-map [v] -map [a] ./tmp/output.mp4
这不会出错,但会创建一个似乎永远不会停止增长的文件。
我对 ffmpeg 还很陌生,但我已经研究了一段时间,但收获不多。任何帮助我都会很感激!
以下是每个文件的详细信息。
1.mp4
Input #0, matroska,webm, from '1.mp4':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #0:1(eng): Video: vp9 (Profile 0), yuv420p(tv), 1620x910, SAR 1:1 DAR 162:91, 24.83 fps, 24.83 tbr, 1k tbn (default)
Metadata:
alpha_mode : 1
2.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf59.27.100
Duration: 00:00:09.05, start: 0.000000, bitrate: 793 kb/s
Stream #0:0[0x1](und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Video: mjpeg (Progressive) (mp4v / 0x7634706D), yuvj420p(pc, bt470bg/unknown/unknown), 4963x3062 [SAR 72:72 DAR 4963:3062], 164635 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
3.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf59.27.100
Duration: 00:00:10.20, start: 0.000000, bitrate: 957 kb/s
Stream #0:0[0x1](eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, mono, fltp, 50 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Video: png (mp4v / 0x7634706D), rgb24(pc), 2667x1500 [SAR 7874:7874 DAR 889:500], 230945 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
4.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '4.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:02:12.08, start: 0.000000, bitrate: 311 kb/s
Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 566x720 [SAR 1:1 DAR 283:360], 174 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0]