I have lots of files with multiple audio and subtitle languages, however the track numbers aren't consistent (the English audio stream isn't always the first) so using a command such as:
ffmpeg -i "input.mkv" -map 0 -map -0:a:1 -c:v copy -c:a copy "output.mkv"
doesn't yield expected results. After searching around I discovered it was possible to map streams based on language with this command:
ffmpeg -i "input.mkv" -map 0 -map -0:m:language:eng -c:v copy -c:a copy "output.mkv"
However -map -0:m:language:eng
will remove all tracks with the English language flag. To keep the subtitle tracks you can use -map 0:s
this is a good solution however, I want to know if it's possible to only map audio streams based on language. I.e.,
I want to remove English audio while retaining all other streams without using stream IDs.
-0:m:language:eng
will remove english audio tracks and keep all others.
to keep only english audio tracks and remove all others, remove the dash at the beginning: 0:m:language:eng
the dash at the beginning creates a negative mapping, which tells ffmpeg "remove this and only things that match this"
i know this is 8 months later, but i thought it would be helpful for those who end up here off of google searches like i did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With