ffmpeg batch files
The most efficient method is to use negative mapping in the -map option to exclude specific stream(s) ("tracks") while keeping all other streams.
Remove a specific audio stream / track
ffmpeg -i input -map 0 -map -0:a:2 -c copy output
-map 0selects all streams from the input.-map -0:a:2then deselects audio stream 3. The stream index starts counting from 0, so audio stream 10 would be0:a:9.
Remove all audio streams / tracks
ffmpeg -i input -map 0 -map -0:a -c copy output
-map 0selects all streams from the input.-map -0:athen deselects all audio streams from the input.
Remove specific audio streams / tracks
Keep everything except audio streams #4 (at offset 3) and #7 (at offset 6):
ffmpeg -i input -map 0 -map -0:a:3 -map -0:a:6 -c copy output
Remove all subtitles and data
ffmpeg -i input -map 0 -map -0:s -map -0:d -c copy output
Only include video and audio
This example does not need to use any negative mapping.
ffmpeg -i input -map 0:v -map 0:a -c copy output
Removing other stream / track types
If you want to remove other stream types you can use the appropriate stream specifier.
v- video, such as-map -0:va- audio, such as-map -0:a(as shown above)s- subtitles, such as-map -0:sd- data, such as-map -0:dt- attachments, such as-map -0:t
Extract or remove a specific audio channel
Using a stereo input and channelsplit filter. Example to get the right channel only and output a mono audio file:
ffmpeg -i stereo.wav -filter_complex "[0:a]channelsplit=channel_layout=stereo:channels=FR[right]" -map "[right]" front_right.wav
channel_layoutis the channel layout of the input stream. The default isstereo.channelslists the channels to be extracted as separate output streams. The default isallwhich extracts each input channel as a separate, individual stream.See
ffmpeg -layoutsfor a list of accepted channel layouts (forchannel_layoutoption) and channel names (forchannelsoption).See FFmpeg Wiki: Audio Channels for more examples.