7

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).

Share a link to this question
CC BY-SA 3.0
1
14

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
Share a link to this answer
CC BY-SA 3.0
6
  • Can't use Subtitle Edit under Linux. Your first ffmpeg command failed with error Only text based subtitles are currently supported, but the second worked (video quality was decreased, file output is 3 times smaller....but with subtitles working!!!). Thanks
    – jpo38
    Mar 31 '16 at 10:55
  • You can insert -crf 20 to increase video quality.
    – Gyan
    Mar 31 '16 at 11:07
  • Will try that. Thanks again for your help.
    – jpo38
    Mar 31 '16 at 16:04
  • By the way, could you explain in your post what means this magic 'filter_complex' parameter?
    – jpo38
    Mar 31 '16 at 16:05
  • 2
    You would use two commands: a) ffmpeg -i in.mkv -map 0:s sub.mp4 b) Check if sub.mp4 exists and is non-zero size (alternatively, check if exit code of cmd a is successful). If no, ffmpeg -i in.mkv -c copy -sn out.mp4. If yes, ffmpeg -i in.mkv -c:v copy -c:a copy out.mp4
    – Gyan
    Nov 24 '16 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.