inline Dropping streams from a file

Originally published on May 1st, 2020 (Last updated on May 1st, 2020)

To remove streams (video, audio, sub­ti­tles, etz) from a file, cre­ate a new file and spec­i­fy the appro­pri­ate map­ping of streams:

# Keep all Video streams, only take Audio Stream 1 and 2
ffmpeg -i <file> -map v -map a:1 -map a:2 -c copy <out>

Select­ing spe­cif­ic streams is done by spec­i­fy­ing them to the -map option in the appro­pri­ate for­mat: input:type:index where:

  • input spec­i­fies the index of the input file. Only required if mul­ti­ple input files are given
  • type is the type of stream: a for Audio, v for Video, s for Subtitles
  • index is the 0‑based index of the stream in the input file

The -map argu­ment is an out­put argu­ment, which means it must be spec­i­fied after all input files and argu­ments are spec­i­fied. If it’s spec­i­fied, all streams NOT explic­it­ly mapped are dropped from the out­put file. 

To map all streams as in the input file use -map 0.


No com­ment sec­tion here 😄

You can reach me over at @knuth_dev or send me an Email.