Using ffmpeg on how to copy the video and multiple subtitle streams in an MKV and reencode multiple audio streams into AC3

audioffmpegvideo

I have a video file in MKV format. I like the quality of the video, but I dislike having the audio in FLAC format since I decided it takes up too much space.

It is a dual audio file—it’s an anime with Japanese and English audio—and it has several subtitle streams inside as well.

This is the command I use:

ffmpeg -i "01.mkv" -c:v copy -c:a ac3 -c:s copy "test.mkv"

However it only gets the first audio and first subtitle string. I need help with the map option for multiple streams.

Best Answer

I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v

This should make your command

ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"

The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.

Related Question