Include external subtitles while converting video with FFmpeg

Is it possible to use subtitles from an external file while converting a video with FFmpeg? The file extension of the subtitles is .stl or .vob.


Converting subtitles

ffmpeg -i input1.mp4 -i input2.srt -c copy -map 0 -map 1 output.mkv

This will take subtitles in from the srt, and every stream from the MP4. It should work with most subtitle formats. This particular command line will copy all video, audio and subtitle streams.

ffmpeg can also automatically choose a matching subtitle format for the output, e.g. it will convert the .srt subtitles to ASS for the following command:

ffmpeg -i input1.mp4 -i input2.srt -c:a copy -c:v copy -map 0 -map 1 

output.mkv

Hardcoding subtitles

FFmpeg can also hardcode subtitles into the video, using the subtitles filter:

ffmpeg -i input1.mp4 -c:v libx264 -vf "subtitles=input2.srt" -c:a copy output.mkv

Note that re-converting the video is necessary here.

Supported subtitle formats

As of 2017, it will decode/encode (D/E) the following subtitle formats:

 D E   ass                  ASS (Advanced SSA) subtitle (decoders: ssa ass ) (encoders: ssa ass )
 D E   dvb_subtitle         DVB subtitles (decoders: dvbsub ) (encoders: dvbsub )
 D E   dvd_subtitle         DVD subtitles (decoders: dvdsub ) (encoders: dvdsub )
 D     eia_608              EIA-608 closed captions (decoders: cc_dec )
 D     hdmv_pgs_subtitle    HDMV Presentation Graphic Stream subtitles (decoders: pgssub )
 D     jacosub              JACOsub subtitle
 D     microdvd             MicroDVD subtitle
 D E   mov_text             MOV text
 D     mpl2                 MPL2 subtitle
 D     pjs                  PJS (Phoenix Japanimation Society) subtitle
 D     realtext             RealText subtitle
 D     sami                 SAMI subtitle
 D     stl                  Spruce subtitle format
 D E   subrip               SubRip subtitle (decoders: srt subrip ) (encoders: srt subrip )
 D     subviewer            SubViewer subtitle
 D     subviewer1           SubViewer v1 subtitle
 D E   text                 raw UTF-8 text
 D     vplayer              VPlayer subtitle
 D E   webvtt               WebVTT subtitle
 D E   xsub                 XSUB