Table of Contents

ffmpeg - Decoding - Extract some streams

Check what streams exist

ffmpeg -i inputfile

returns:

Stream #0:0: Video: hevc .....
Stream #0:1(eng): Audio: aac ....
Stream #0:2(eng): Subtitle: ...
Stream #0:3(fre): Audio: aac ....
Stream #0:4(fre): Subtitle: aac ....

Extract some streams

ffmpeg -i inputfile.mkv -map 0:0 -map 0:1 -map 0:2 -c:v libx264 -preset fast -crf 25 -c:a copy -c:s copy english-output.mp4

NOTE: This extracts only the Video, English audio and Subtitles; but encodes the video (fast crf 25):

  • Processing what you mapped is done sequentially.
    • -map 0:0 is the Video stream; because the -c:v is the first action and therefore goes to this 1st mapping.
    • -map 0:1 is the Audio stream, because the -c:a copy is the second action and therefore goes to this 2nd mapping.
    • -map 0:2 is the Subtitles stream, because the -c:s copy is the third action and therefore goes to this 3rd mapping.
  • There are shortcuts too, that could be used:
    • -map 0:v selects all the video type streams.
    • -map 0:a selects all the audio type streams.