Включить внешние субтитры при конвертации видео с помощью FFmpeg

3342
user20722

Можно ли использовать субтитры из внешнего файла при конвертации видео с помощью FFmpeg? Расширение файла субтитров - .stl или .vob.

4

1 ответ на вопрос

3
evilsoup

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 
Я получил смешанные результаты с автоматическим преобразованием, но попытка скопировать субтитры с помощью MKV (который поддерживает практически все) должна работать нормально. slhck 11 лет назад 0

Похожие вопросы