Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't change video subtitles codec using ffmpeg

Tags:

video

ffmpeg

I've got a mkv file with somes streams embedded:

Stream #0:0: Video: h264 (High), yuv420p(tv, smpte170m/smpte170m/bt709), 720x300, SAR 1:1 DAR 12:5, 25 fps, 25 tbr, 48003.07 tbn, 50 tbc (default)
Stream #0:1(tr): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Stream #0:2(fr): Subtitle: dvd_subtitle, 720x300

When playing on my PC, I can see subtitles. When playing it from my old DVD/DIVX player, I cannot see the subtitles (other mkv/avi work fine).

So I wanted to change the subtitle encoding, to see if another one could work with my DVD player.

ffmpeg -encoders reports:

 S..... ssa                  ASS (Advanced SubStation Alpha) subtitle (codec ass)
 S..... ass                  ASS (Advanced SubStation Alpha) subtitle
 S..... dvbsub               DVB subtitles (codec dvb_subtitle)
 S..... dvdsub               DVD subtitles (codec dvd_subtitle)
 S..... mov_text             3GPP Timed Text subtitle
 S..... srt                  SubRip subtitle (codec subrip)
 S..... subrip               SubRip subtitle
 S..... text                 Raw text subtitle
 S..... webvtt               WebVTT subtitle
 S..... xsub                 DivX subtitles (XSUB)

So I tried:

ffmpeg -i input.mkv -acodec copy -vcodec copy -scodec "codec" converted.mkv

with various versions of "codec". None of them will work (except the original dvdsub...):

xsub reports:

[matroska @ 0x24558c0] Subtitle codec 94211 is not supported.
av_interleaved_write_frame(): Function not implemented
[matroska @ 0x24558c0] Subtitle codec 94211 is not supported.
Error writing trailer of mustang_converted.mkv: Function not implementedframe=  244 fps=0.0 q=-1.0 Lsize=       1kB time=00:00:10.01 bitrate=   1.0kbits/s speed=1.23e+03x    
video:321kB audio:235kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!

ssa or ass reports:

[ssa @ 0x262e000] Only SUBTITLE_ASS type supported.
Subtitle encoding failed

others reports:

Error while opening encoder for output stream #0:2 - maybe incorrect parameters such as bit_rate, rate, width or height

What am I doing wrong? Are some subtitles codec incompatible with the current video or audio codec? Should I change those instead of copying?

Alternatively, is there an option to merge subtitle within the video images stream for good (and then have only two output streams: audio and video but preserve subtitles display)?

Note: Answer using another tool than ffmpeg are acceptable, if working under Linux (mint).

like image 271
jpo38 Avatar asked Mar 31 '16 07:03

jpo38


1 Answers

Your subtitles are image-based and need to be converted to a text-based format like SRT. Use Subtitle Edit or similar tool to import the subs from MKV. This will do OCR processing of the subs. Once done, save as SRT or any common text-based subtitle format.

Then run your ffmpeg command with scodec of your choice.


Alternatively, if you want to burn in the subtitles, you can try one of these methods

ffmpeg -i input.mkv -vf subtitles=input.mkv -acodec copy -sn converted.mkv

or

ffmpeg -i input.mkv -filter_complex "[0:v:0][0:2]overlay" -acodec copy -sn converted.mkv
like image 140
Gyan Avatar answered Oct 21 '22 06:10

Gyan