user14116: I have .mp4 files created by a Sony A7s camera. They're using the XAVC S codec. I'm converting them to .mov using the command below. The original files have a timecode but that is not present in the output file. The output files have their timecodes set to zero. Is there any way to preserve the timecode?
ffmpeg -i [filenmae] -vcodec copy -acodec copy [outputDirectory]


user1871: Just use copy for all streams i.e. 
ffmpeg -i [filename] -c copy -map 0 [outputDirectory]


Edit: Let's switch byte-order
ffmpeg -i [filename] -c copy -c:a pcm_s16le -map 0 [outputDirectory]


user20549: In case someone else comes looking for this, timecode in mp4 and mov files is often a "data" track, and ffmpeg usually drops data tracks. To keep all tracks, I usually use these switches to map tracks from the source to tracks in the destination
-map 0:v (video switches)
-map 0:a (audio switches)
-map 0:d (this keeps the data track)

Which also has the advantage of keeping all the source audio tracks, rather than the default of only the first one. So your command might look like
ffmpeg -i [filename] -map 0:v -codec:v copy -map 0:a -codec:a copy -map 0:d [outputDirectory]

EDIT: In modern ffmpeg you can also add a question mark (like -0:a?) which means ffmpeg will keep going if it doesn't find a track like you asked it to copy

user35530: 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


14116: <p>I have <code>.mp4</code> files created by a Sony A7s camera. They're using the XAVC S codec. I'm converting them to <code>.mov</code> using the command below. The original files have a timecode but that is not present in the output file. The output files have their timecodes set to zero. Is there any way to preserve the timecode?</p>

<pre><code>ffmpeg -i [filenmae] -vcodec copy -acodec copy [outputDirectory]
</code></pre>
 1871: <p>Just use copy for all streams i.e. </p>

<pre><code>ffmpeg -i [filename] -c copy -map 0 [outputDirectory]
</code></pre>

<hr>

<p><strong>Edit</strong>: Let's switch byte-order</p>

<pre><code>ffmpeg -i [filename] -c copy -c:a pcm_s16le -map 0 [outputDirectory]
</code></pre>
 20549: <p>In case someone else comes looking for this, timecode in mp4 and mov files is often a &quot;data&quot; track, and ffmpeg usually drops data tracks. To keep all tracks, I usually use these switches to map tracks from the source to tracks in the destination</p>
<pre><code>-map 0:v (video switches)
-map 0:a (audio switches)
-map 0:d (this keeps the data track)
</code></pre>
<p>Which also has the advantage of keeping all the source audio tracks, rather than the default of only the first one. So your command might look like</p>
<pre><code>ffmpeg -i [filename] -map 0:v -codec:v copy -map 0:a -codec:a copy -map 0:d [outputDirectory]
</code></pre>
<p>EDIT: In modern ffmpeg you can also add a question mark (like -0:a?) which means ffmpeg will keep going if it doesn't find a track like you asked it to copy</p>
 35530: <h2>Short answer specific to this problem:</h2>
<p>Use this option:</p>
<pre><code>-map_metadata 0:s:2
</code></pre>
<h2>Explanation:</h2>
<p>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.</p>
<p>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:</p>
<pre class="lang-bash prettyprint-override"><code>ffmpeg -i inputfile.mp4
</code></pre>
<p>This will display info about all the input streams, including the metadata.</p>
<p>Example output (excerpts):</p>
<pre><code>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
</code></pre>
<p>Now, note that timecode is attached as metadata to a separate 'data' stream, which needs to be present in the output for a simple <code>-map_metadata 0</code> to work. Since it cannot be copied, we need to map that metadata to the global metadata of the file itself.</p>
<p>Note down the stream number containing the timecode, in this example stream 2 of input 0, and map it to global metadata using <code>-map_metadata 0:s:2</code>.</p>
<pre class="lang-bash prettyprint-override"><code>ffmpeg -i inputfile.mp4 -map_metadata 0:s:2 -c copy outputfile.mov
</code></pre>
<p>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.</p>
<p>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 <a href="https://ffmpeg.org/ffmpeg-all.html#toc-Advanced-options" rel="nofollow noreferrer">advanced options part of the ffmpeg documentation</a>.</p>
<p>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.</p>
<p><strong>The resulting file will have a timecode recognizable in editing software like DaVinci Resolve and Premiere Pro.</strong></p>
<p>I tried other options like <code>-write_tmcd</code> and several forms of  <code>-map 0</code> with and without <code>-copy_unknown</code> but they didn't work, probably because ffmpeg currently needs to understand what it is copying.</p>
<p>Note that this does not copy the whole data stream, just its metadata. For our current requirement this is okay.</p>
<p>Also, since I was converting to prores422hq, my exact command (that worked) was this:</p>
<pre><code>ffmpeg -i inputfile.mp4 -map_metadata 0:s:2 -c:v prores_ks -profile hq -c:a pcm_s16le outputfile.mov
</code></pre>
