How to extract specific audio track (track 2) from mp4 file using ffmpeg?

Solution 1:

You can use the -map option to choose specific streams. To get a list of the available streams, run ffmpeg -i INPUT_FILE.EXT (Do not forget -i!), which gives e.g.:

…
Input #0, EXT, from 'INPUT_FILE.EXT':
  Metadata:
    encoder         : VirtualDubMod 1.5.10.2 (build 2542/release)
  Duration: 01:35:35.88, start: 0.000000, bitrate: 1029 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 891 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
  title           : English AC3 2.0 (Stereo) @ 128 kbps
    Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 192 kb/s
Metadata:
  title           : English AC3 2.0 (Stereo) @ 192 kbps
At least one output file must be specified

If you want to extract e.g. stream #0:2, use -map 0:2:

ffmpeg -i INPUT_FILE.EXT -map 0:2 OUTPUT_FILE.EXT

Further reading

  • ffmpeg Wiki page about the -map option
  • man ffmpeg/OPTIONS/Advanced options/-map