如何使用 ffmpeg 合并多个.mp4文件?(相同的编码器,简单的合并即可)



我在尝试:

  • 如何使用 FFmpeg 连接两个 MP4 文件?
  • https://superuser.com/questions/1059245/ffmpeg-join-two-mp4-files-with-ffmpeg-on-command-line

选项 A:

ffmpeg -f concat -i list.txt -c copy output

第 1 行:未知关键字"文件" list.txt:处理输入时发现无效数据

cat list.txt file './001-eclipse.mp4' file './002-sundown.mp4' file './003-robothear.mp4' file './004-NOPE-boring-tower.mp4'

选项 B:

ffmpeg -i "concat:001-eclipse.mp4|002-sundown.mp4|003-robothear.mp4|004-NOPE-boring-tower.mp4" -c copy output.mp4

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7feb1d001200] Found duplicated MOOV Atom. Skipped it Last message repeated 2 times Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:001-eclipse.mp4|002-sundown.mp4|003-robothear.mp4|004-NOPE-boring-tower.mp4': Metadata: encoder : Lavf58.12.100 major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 Duration: 00:00:13.64, start: 0.000000, bitrate: 161885 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 5376x2688, 54015 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Output #0, mp4, to 'output.mp4': Metadata: compatible_brands: isomiso2avc1mp41 major_brand : isom minor_version : 512 encoder : Lavf58.12.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 5376x2688, q=2-31, 54015 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default) Metadata: handler_name : VideoHandler Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help frame= 341 fps=0.0 q=-1.0 Lsize= 89943kB time=00:00:13.52 bitrate=54497.5kbits/s speed=90.2x video:89937kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005972%

它只包含第一个视频:/


有什么想法吗?

我在 Mac 上的版本:

ffmpeg -version ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.100

它确实对我有用。我正在使用 Windows 10。

我用这个作为来源[https://trac.ffmpeg.org/wiki/Concatenate]。

我所有的mp4文件和list.txt都在同一个文件夹中。

我的list.txt文件是:

file '20190710_141637.mp4'
file '20190710_144949.mp4'
file '20190710_153155.mp4'
file '20190710_160506.mp4'

然后我运行命令:

ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4

输出为:

ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100
libpostproc    55.  3.100 / 55.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0650ce00] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: 17259 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17003 kb/s, SAR 1:1 DAR 16:9, 30.01 fps, 30 tbr, 90k tbn, 180k tbc
Metadata:
rotate          : 90
creation_time   : 2019-07-10T17:49:48.000000Z
handler_name    : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s
Metadata:
creation_time   : 2019-07-10T17:49:48.000000Z
handler_name    : SoundHandle
Output #0, mp4, to 'output.mp4':
Metadata:
encoder         : Lavf58.20.100
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17003 kb/s, 30.01 fps, 30 tbr, 90k tbn, 90k tbc
Metadata:
rotate          : 90
creation_time   : 2019-07-10T17:49:48.000000Z
handler_name    : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s
Metadata:
creation_time   : 2019-07-10T17:49:48.000000Z
handler_name    : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0650ce00] Auto-inserting h264_mp4toannexb bitstream filtereed=33.1x
[mov,mp4,m4a,3gp,3g2,mj2 @ 0650ce00] Auto-inserting h264_mp4toannexb bitstream filterpeed=33.1x
[mov,mp4,m4a,3gp,3g2,mj2 @ 065bf040] Auto-inserting h264_mp4toannexb bitstream filterpeed=29.6x
frame=208306 fps=922 q=-1.0 Lsize=14635199kB time=01:55:42.00 bitrate=17270.5kbits/s speed=30.7x
video:14409412kB audio:216937kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.060511%

最新更新