0

I’m developing an app that needs to clone an MP4 video file with all the streams using FFmpeg C++ API and have successfully made it work based on the FFmpeg remuxing example.

This works great for video and audio streams, but when the video includes a data stream (actually a QuickTime Time Code according to MediaInfo) I get this error.

Output #0, mp4, to 'C:\Users\user\Desktop\shortOut.mp4':
    Stream #0:0: Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv,progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 1208 kb/s
    Stream #0:1: Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 32s
    Stream #0:2: Data: none (tmcd / 0x64636D74), 0 kb/s
[mp4 @ 0000000071edf600] Could not find tag for codec none in stream #2, codec not currently supported in container

I’ve found this happens in the call to avformat_write_header().

It makes sense that if FFmpeg doesn’t know the codec it can’t write to the header about it, but I found out that using the ffmpeg command line I can make it to work perfectly using the copy command for the stream, something like:

ffmpeg -i input.mp4 -c:v copy -c:a copy -c:a copy output.mp4

I have been analyzing ffmpeg.c implementation to try to understand how they do a stream copy, but it’s been very painful following along the huge pipeline.

What would be a proper way to remux a data stream of this type with FFmpeg C++ API? Any tip or pointers?

Maxito
  • 619
  • 11
  • 26
  • 1
    The timecode track is just a single packet written at the front of the `mdat`. See lavf/movenc.c for how the trak box is written for this type. – Gyan Sep 14 '18 at 05:58
  • @Gyan I understand, but in this case it is embedded into a Data Stream in the source video (stream #2 in quoted error) and I need to do a stream copy to maintain it as the source. But after calling the write_header() it gives me that error – Maxito Sep 17 '18 at 15:44
  • 1
    No, that's just how ffmpeg displays its presence. See how the option `-write_tmcd` is implemented. – Gyan Sep 17 '18 at 15:56
  • @Gyan doing a test using the -timecode parameter with ffmpeg command line app seems to generate a timecode data stream too, so your idea is correct. It's just confusing ffmpeg shows it as a stream. I will check the -timecode implementation and see what I can get from it. Thank you! – Maxito Sep 17 '18 at 16:06

0 Answers0