0

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.

1 Answer 1

0

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

  1. 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
    
  2. Extract the audio stream into a temporary M4A file:

    ffmpeg -i original_video.mp4 -map a:0 -codec copy  audio.m4a
    
  3. 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.