1

I want to concatenate two GoPro videos losslessly with that FFmpeg command:

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"

with list_videos.txt containing:

file 'a.MP4'
file 'b.MP4'

That works fine. The extra attributes -map 0:v -map 0:a -map 0:3 -copy_unknown -tag:2 gpmd keeps the telemetry information.

Since a.MP4 is a bit too long and I just want to keep the first 10 seconds of it, I run the following FFmpeg command to keep the first 10 seconds of it:

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

That works fine. However, when I try to concatenate a_only_the_first_8secs.MP4 with b.MP4 using the aforementioned command (ffmpeg -safe 0 -f concat [...]), it fails with that error:

[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

What's the issue?


Full log:

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
Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400

1 Answers1

1

Your input gpmd track in the trimmed input is 0:2, not 0:3.

Instead, trim the file like this,

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

Keep the concat command the same.

Gyan
  • 38,955