2

I created a video using Final Cut Pro X (10.1.4) and added a commentary using the voiceover feature. I was surprised to discover that FCPX does not support outputting a file with multiple audio tracks.

I disabled the commentary track and saved the project in 1080p with just the regular audio (main.m4v).

I then re-enabled the commentary and adjusted the regular audio and exported a 720p version with just the commentary track (commentary.m4v).

How do I use ffmpeg to create final.m4v, which would be main.m4v but with the audio track from commentary.m4v as a secondary audio track?

  • maybe you could refer to https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg – Kokizzu Jan 28 '15 at 03:23
  • That solution talks about replacing the existing audio or mixing the two audio tracks into one. I want to rip the audio from one m4v file and add it as a second separate track to an existing m4v. –  Jan 28 '15 at 03:47
  • ah my bad, I misunderstood the question, you may use this answer: http://askubuntu.com/questions/317739/how-to-add-an-additional-sound-track-to-an-existing-video if you could compromise with `ffmpeg`-only – Kokizzu Jan 28 '15 at 03:49
  • 1
    Thanks! With that example, I got some very interesting results. I got a m4v that works exactly how I want in VLC, but with quicktime, it doesn't let me pick an audio track and plays both at the same time. I need to do some research on this, but I am definitely close to what I am after. –  Jan 28 '15 at 04:10

2 Answers2

2

Use the mapping options:

ffmpeg -i main.m4v -i commentary.m4v -c copy -map 0:v -map 0:a -map 1:a final.m4v

With -map, the first number in the option refers to the index of the input file (i.e., 0 is the first). The options therefore mean:

  • Copy all bitstreams instead of re-encoding
  • Take the (first) video stream of the first input
  • Take the (first) audio stream of the first input
  • Take the (first) audio stream of the second input

All streams that have a map option are then copied over.

You could also explicitly refer to a numbered video/audio stream, e.g. 0:a:1, to refer to the second audio stream in the first file, in case there is any.

slhck
  • 223,558
  • 70
  • 607
  • 592
0

If it's not specific to ffmpeg you could use this example

The MKVmerge or MP4Box tool could append a track on existing video.

Kokizzu
  • 1,715
  • 3
  • 16
  • 26