Short answer specific to this problem:
Use this option:
-map_metadata 0:s:2
Explanation:
Timecode often comes in a format specific to the file format, so ffmpeg can't be expected to just 'copy' it without getting explicit instructions.
In Sony a7siii 4k 10bit footage mp4 file, there is a separate 'data' stream to which it is added as a metadata. It is usually stream indexed 2 (the third stream), but you can use this command to determine it for yourself:
ffmpeg -i inputfile.mp4
This will display info about all the input streams, including the metadata.
Example output (excerpts):
ffmpeg version...
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inputfile.mp4':
Metadata:
...
Stream #0:0(und): Video: h264...
...
Stream #0:2(und): Data: none (rtmd / 0x646D7472), 2252 kb/s (default)
Metadata:
creation_time : 2021-06-19T16:39:17.000000Z
handler_name : Timed Metadata Media Handler
timecode : 07:15:07:17
Now, note that timecode is attached as metadata to a separate 'data' stream, which needs to be present in the output for a simple -map_metadata 0
to work. Since it cannot be copied, we need to map that metadata to the global metadata of the file itself.
Note down the stream number containing the timecode, in this example stream 2 of input 0, and map it to global metadata using -map_metadata 0:s:2
.
ffmpeg -i inputfile.mp4 -map_metadata 0:s:2 -c copy outputfile.mov
This should map metadata of the stream indexed 2 (s:2) from the first input (0:) to the global (default) metadata of the output file, and copy audio-video streams as they are.
Note that the numbering and the meaning of 's' is different than how it is in other more common options. Check more info in the advanced options part of the ffmpeg documentation.
ffmpeg then reads whatever it understands from that stream's metadata (which includes timecode), converts it to the destination file format's ideal metadata format, and includes it in the output.
The resulting file will have a timecode recognizable in editing software like DaVinci Resolve and Premiere Pro.
I tried other options like -write_tmcd
and several forms of -map 0
with and without -copy_unknown
but they didn't work, probably because ffmpeg currently needs to understand what it is copying.
Note that this does not copy the whole data stream, just its metadata. For our current requirement this is okay.
Also, since I was converting to prores422hq, my exact command (that worked) was this:
ffmpeg -i inputfile.mp4 -map_metadata 0:s:2 -c:v prores_ks -profile hq -c:a pcm_s16le outputfile.mov