Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE

This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

FFmpeg Select Default English Audio Track

A collection of useful tutorials for some common tasks.

FFmpeg Select Default English Audio Track

Postby Voldrix » Sun Oct 04, 2015 1:07 am

If you are scripting multiple transcodes, and the audio file you want is not always the same stream number, this is very frustrating.
If you have files with metadata about the streams, you can possibly use this
Code: Select all
ffmpeg -i file.mp4 -map 0:v:0 -map 0:m:language:eng -c copy -sn out.mp4

In the more likely event you have a dvd/iso/no metadata, we have to create our own method. in bash, replace $title and $chapter with appropriate integer or integer range 1,1-99
Code: Select all
audio=`tccat -i "disk.iso" -d 0 -T $title,$chapter,1 2>/dev/null | ffprobe - 2>&1 | grep '0x80' | awk '{print $2}' | sed 's/#0:\([0-9]\).*/\1/'`

if 0x80 is not the stream you need, replace it with whatever is. this will be consistent across the dvd, and the command will return the stream number it is.
you can find the stream id with
Code: Select all
tccat -i "disk.iso" -d 0 -T $title,1,1 2>/dev/null | ffprobe -

then you just use the audio var in your transcode script
Code: Select all
tccat -i "disk.iso" -d 0 -T 1,1-99,1 2>/dev/null | ffmpeg -i - -map 0:v:0 -map 0:$audio -c copy -sn -map_chapters -1 -map_metadata -1 "out.mp4"

you will need the transcode package. lsdvd is useful too.
Here is my all-in-one FFmpeg compile, install, clean up script for Debian and Debian based OS's, like Ubuntu. run as root. http://voldrixia.com/files/ffmpeg_install
Posts: 1
Joined: Sun Oct 04, 2015 12:09 am

Re: FFmpeg Select Default English Audio Track

Postby llogan » Sun Oct 04, 2015 3:14 am

-map can use stream id:
Code: Select all
-map i:0x80
Get an answer more quickly by providing your actual ffmpeg command and the complete console output. Use the code button to format your command and output or your question will be ignored.
Posts: 2337
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests