我想用 FFmpeg 命令无损连接两个 GoPro 视频:
ffmpeg -safe 0 -f concat -i "list_videos.txt" -map 0:v -map 0:a -map 0:3 -copy_unknown -tag:2 gpmd -c copy "ab.mp4"
包含list_videos.txt
:
file 'a.MP4'
file 'b.MP4'
效果很好。额外的属性-map 0:v -map 0:a -map 0:3 -copy_unknown -tag:2 gpmd
保留了遥测信息。
由于a.MP4
有点太长,我只想保留前 10 秒,所以我运行以下 FFmpeg 命令来保留前 10 秒:
ffmpeg -sseof -10 -i a.MP4 -map 0:v -map 0:a -map 0:3 -copy_unknown -tag:2 gpmd -c copy a_only_the_first_10secs.MP4
这很好用。但是,当我尝试使用上述命令 ( )a_only_the_first_8secs.MP4
进行连接时,它会失败并显示以下错误:b.MP4
ffmpeg -safe 0 -f concat [...]
[mp4 @ 000001ba70009980] Tag gpmd incompatible with output codec id '0' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
有什么问题?
完整日志:
C:\vids\test>ffmpeg -safe 0 -f concat -i "list_videos.txt" -map 0:v -map 0:a -map 0:3 -copy_unknown -tag:2 gpmd -c copy "merged_vid.mp4"
ffmpeg version 5.0.1-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, 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-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --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-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 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
[concat @ 000001ba6ffa6440] Could not find codec parameters for stream 3 (Unknown: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, concat, from 'list_videos.txt':
Duration: N/A, start: -0.026667, bitrate: 59900 kb/s
Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59651 kb/s, 59.94 fps, 59.94 tbr, 60k tbn
Metadata:
handler_name : GoPro H.265
vendor_id : [0][0][0][0]
timecode : 00:05:46:57
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s
Metadata:
handler_name : GoPro AAC
vendor_id : [0][0][0][0]
Stream #0:2(eng): Data: bin_data (gpmd / 0x646D7067), 59 kb/s
Metadata:
handler_name : GoPro MET
Stream #0:3: Unknown: none
[mp4 @ 000001ba70009980] Tag gpmd incompatible with output codec id '0' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:2 --
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:3 -> #0:2 (copy)
Last message repeated 1 times
您在修剪输入中输入的 gpmd 轨道是 0:2,而不是 0:3。
相反,像这样修剪文件,
ffmpeg -sseof -10 -i a.MP4 -map 0:v -map 0:a -map 0:3 -map 0:3 -copy_unknown -tag:2 gpmd -tag:3 gpmd -c copy a_only_the_first_10secs.MP4
保持 concat 命令不变。