I have a bunch of video files with multiple audio and subtitle streams (in different languages). The streams contain metadata specifying which stream is which langauge. I want to copy all files but maintaining only the spanish audio streams, and the english subtitle streams (and the video stream of course).
Unfortunately, not all videos contain the same language streams at the same index, so instead of using something like -map 0:a:2
I am trying to select the streams based on metadata.
However, if I try the following: (based on answers found in similar questions like this and this)
ffmpeg -i input.mkv -map 0:v -map 0:a:m:language:spa -map 0:s:m:language:eng -c copy output.mkv
It still copies the first audio and first subtitle stream, no matter which stream is which language. In other words, this behaves just like -map 0:v -map 0:a:0 -map 0:s:0
which isn't what I need.
Is there a different map
argument I can use to make sure it picks only the spanish audio stream and only the english subtitle stream, regardless of their index in the input file?