我需要通过以下方式连接不同分辨率的 n 个 mp4 视频ffmpeg。但是,尽管在filter_complex
执行连接操作之前我将所有视频缩放到相同的分辨率,但我还是收到错误:
包含 3 个视频的命令示例:
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex "[0:v]scale=1024:576:force_original_aspect_ratio=1[v0]; [1:v]scale=1024:576:force_original_aspect_ratio=1[v1]; [2:v]scale=1024:576:force_original_aspect_ratio=1[v2]; [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" -map [v] -map [a] output.mp4
输出:
$ ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex "[0:v]scale=1024:576:force_original_aspect_ratio=1[v0]; [1:v]scale=1024:576:force_original_aspect_ratio=1[v1]; [2:v]scale=1024:576:force_original_aspect_ratio=1[v2]; [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" -map [v] -map [a] output.mp4
ffmpeg version 2023-08-28-git-b5273c619d-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 58. 17.100 / 58. 17.100
libavcodec 60. 23.100 / 60. 23.100
libavformat 60. 10.101 / 60. 10.101
libavdevice 60. 2.101 / 60. 2.101
libavfilter 9. 11.100 / 9. 11.100
libswscale 7. 3.100 / 7. 3.100
libswresample 4. 11.100 / 4. 11.100
libpostproc 57. 2.100 / 57. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-10-08T12:31:56.000000Z
Duration: 00:03:15.51, start: 0.000000, bitrate: 464 kb/s
Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1444x876 [SAR 1:1 DAR 361:219], 335 kb/s, 30 fps, 30 tbr, 30k tbn (default)
Metadata:
creation_time : 2021-10-08T12:31:56.000000Z
handler_name : Mainconcept MP4 Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2021-10-08T12:31:56.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2023-02-28T15:42:03.000000Z
Duration: 00:03:00.70, start: 0.000000, bitrate: 518 kb/s
Stream #1:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1796x970 [SAR 1:1 DAR 898:485], 390 kb/s, 30 fps, 30 tbr, 30k tbn (default)
Metadata:
creation_time : 2023-02-28T15:42:03.000000Z
handler_name : Mainconcept MP4 Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #1:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2023-02-28T15:42:03.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video3.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2023-02-27T11:18:11.000000Z
Duration: 00:03:00.67, start: 0.000000, bitrate: 589 kb/s
Stream #2:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 1800x970 [SAR 1:1 DAR 180:97], 461 kb/s, 30 fps, 30 tbr, 30k tbn (default)
Metadata:
creation_time : 2023-02-27T11:18:11.000000Z
handler_name : Mainconcept MP4 Video Media Handler
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #2:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2023-02-27T11:18:11.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
vendor_id : [0][0][0][0]
File 'output.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 (h264) -> scale:default
Stream #0:1 (aac) -> concat
Stream #1:0 (h264) -> scale:default
Stream #1:1 (aac) -> concat
Stream #2:0 (h264) -> scale:default
Stream #2:1 (aac) -> concat
concat -> Stream #0:0 (libx264)
concat -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_concat_3 @ 000001c73586c800] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586c800] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while filtering: Invalid argument
[Parsed_concat_3 @ 000001c73586b300] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586b300] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[Parsed_concat_3 @ 000001c73586c600] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586c600] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[Parsed_concat_3 @ 000001c73586ce00] Input link in0:v0 parameters (size 1024x553, SAR 248297:248320) do not match the corresponding output link in0:v0 parameters (949x576, SAR 69312:69277)
[Parsed_concat_3 @ 000001c73586ce00] Failed to configure output pad on Parsed_concat_3
[fc#0 @ 000001c735837640] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
[out#0/mp4 @ 000001c73710c900] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0kB time=N/A bitrate=N/A speed=N/A
Conversion failed!
针对此问题提供的解决方案这个问题部分解决了问题,因为第二个连接的视频没有音频(第一个有音频),但我仍然不知道如何将解决方案扩展到 3 个或更多视频。有人知道如何帮助我吗?