Convert specific video and audio track only with ffmpeg
Solution 1:
You can use the -map
option (full documentation) to select specific input streams and map them to your output.
The most simple map
syntax you can use is -map i:s
, where i
is the input file ID and s
is the stream ID, both starting with 0
. In your case, that means we select track 0
and 4
:
ffmpeg -i vidui.mkv -c:v libx264 -c:a ac3 -crf 20 -map 0:0 -map 0:4 vidui.mp4
If you want to choose video, audio or subtitle tracks specifically, you can also use stream specifiers:
ffmpeg -i vidui.mkv -c:v libx264 -c:a ac3 -crf 20 -map 0:v:0 -map 0:a:1 vidui.mp4
Here, 0:v:0
is the first video stream and 0:a:1
is the second audio stream.