ffmpeg subtitles

Removing all subtitles from a media file

1
ffmpeg -i input.mkv -map 0 -map -0:s -codec copy output.mkv
  • -map input_file_index:stream_type_specifier:stream_index
  • -map 0 -map -0:s to map all the streams except subtitles streams from input 0, use negative mapping.
  • -codec copy select stream copy mode for the -codec option. This omits decoding and encoding of selected streams.

Adding subtitles to a media file

1
ffmpeg -i input.mkv -i input.srt -map 0 -map 1:s:0 -codec -copy -metadata:s:s:0 langauge=chi output.mkv
  • -map 1:s:0 specifying stream index of #1 input file
  • -metadata:s:s:0 langauge=chi -metadata[:metadata_specifier] key=value. first s is a stream specifier. second s is a subtitle specifier. 0 is the stream index.

reference

Map - ffmpeg