<p>After further research and experimenting, I've figured out how to do it using ffmpeg from command line.</p>
<ol>
<li><p>Extract the relevant video stream (in my case track No. 2, which has index 1) into a temporary MP4 file, using the same codec as the source. The resulting video will have no audio:</p>
<pre><code>ffmpeg -i original_video.mp4 -map v:1 -codec copy  rear_no_audio.mp4
</code></pre>
</li>
<li><p>Extract the audio stream into a temporary M4A file:</p>
<pre><code>ffmpeg -i original_video.mp4 -map a:0 -codec copy  audio.m4a
</code></pre>
</li>
<li><p>Merge the two streams into the final MP4 file.</p>
<pre><code>ffmpeg -i rear_no_audio.mp4 -i audio.m4a -codec copy  rear_with_audio.mp4
</code></pre>
</li>
</ol>
<p>The argument of the -map option includes v for video and a for audio streams. The second digit is the stream ID, which can be found by running</p>
<pre><code>ffprobe original_video.mp4
</code></pre>

CC BY-SA 4.0
2024-03-20T20:47:26.020Z
2024-03-20T21:28:47.400Z
2024-03-20T21:28:47.400Z
Deeday-UK
<p>My Mercedes-Benz dashcam saves to SD card the video feeds from the front and rear cameras (in 1-minute long chunks) as separate tracks in the same MP4 file. Track 1 is from the front camera; track 2 from the rear one.</p>
<p>Unsurprisingly, ordinary players such as Windows built-in ones can only play the first track. VLC player, on the other hand, can play any track no problem. However,  how can I extract say track No. 2 and save it as a single-track MP4 file?</p>
<p>I have tried VLC's Convert/Save function, ticking the De-Interlace box (assuming it matters), but ended up again with a two-track MP4 file.</p>

<ffmpeg><mp4><vlc>
How to extract video tracks from an mp4 file and individually save them to file
Deeday-UK
# How to extract video tracks from an mp4 file and individually save them to file

(Asked by: username_0 on 2024-03-18)

My Mercedes-Benz dashcam saves to SD card the video feeds from the front and rear cameras (in 1-minute long chunks) as separate tracks in the same MP4 file. Track 1 is from the front camera; track 2 from the rear one.

Unsurprisingly, ordinary players such as Windows built-in ones can only play the first track. VLC player, on the other hand, can play any track no problem. However, how can I extract say track No. 2 and save it as a single-track MP4 file?

I have tried VLC's Convert/Save function, ticking the De-Interlace box (assuming it matters), but ended up again with a two-track MP4 file.

**Tags:** ffmpeg, mp4, vlc


---

## 1 answers

### Answer by username_0 on 2024-03-20. Score: 0

After further research and experimenting, I've figured out how to do it using ffmpeg from command line.

Extract the relevant video stream (in my case track No. 2, which has index 1) into a temporary MP4 file, using the same codec as the source. The resulting video will have no audio:
ffmpeg -i original_video.mp4 -map v:1 -codec copy  rear_no_audio.mp4


Extract the audio stream into a temporary M4A file:
ffmpeg -i original_video.mp4 -map a:0 -codec copy  audio.m4a


Merge the two streams into the final MP4 file.
ffmpeg -i rear_no_audio.mp4 -i audio.m4a -codec copy  rear_with_audio.mp4



The argument of the -map option includes v for video and a for audio streams. The second digit is the stream ID, which can be found by running
ffprobe original_video.mp4


---

