Increasing size of subtitle that’s “softly” embedded within mkv

14,158

Well, I did it. It’s not the optimal way, but I was in a hurry. Below is how I solved my problem.

(Also, do not forget to install mkvtoolnix. Linux users can simply pull in the package from their repository, while Windows users can try downloading mkvtoolnix from the official website.)

  1. Run mkvinfo <mkv filename> and get the subtitle index.
  2. Run mkvextract tracks <mkv filename> <subtitle track index>:<mkv filename>.ass
  3. Replace the font sizes of the outputted <mkv filename>.ass with a text editor.
  4. Run mkvmerge -o <new mkv filename> <mkv filename> --language 0:eng <mkv filename>.ass
  5. Transcode <new mkv filename> with HandBrake and watch the transcoded file on TV.

An example with the file dn-01.mkv:

  1. Run mkvinfo dn-01.mkv and the program will print out some information about the mkv file. Look for the subtitle track and its corresponding number. Be sure to use the number within parentheses, since it is the one used for mkvextract. In my case, the subtitle track information was:

    | + A track
    |  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
    |  + Track UID: 476285904
    |  + Track type: subtitles
    |  + Enabled: 1
    |  + Default flag: 1
    |  + Forced flag: 0
    |  + Lacing flag: 0
    |  + MinCache: 0
    |  + Timecode scale: 1
    |  + Max BlockAddition ID: 0
    |  + Codec ID: S_TEXT/ASS
    |  + Codec decode all: 1
    |  + CodecPrivate, length 2057
    |  + Language: eng
    
  2. Run mkvextract tracks dn-01.mkv 2:dn-01.ass and wait.

  3. Open dn-01.ass with some text editor, and change the font sizes under the V4+ Styles header in the beginning of the file. (Remember to change the size of all styles, not just the Default.) Example:

    Style: Default,Marker Felt,27,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,10,10,10,0
    Style: SIGN,Sand,36,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,2,2,10,10,10,0
    (more)
    

    ... becomes ...

    Style: Default,Marker Felt,42,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,10,10,10,0
    Style: SIGN,Sand,54,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,2,2,10,10,10,0
    (more)
    

    Save the file after the changes have been made.

  4. Run mkvmerge -o dn-01-modified.mkv dn-01.mkv --language 0:eng dn-01.ass and wait. After the process has been completed, the newly created dn-01-modified.mkv will have an extra subtitle track, which should be larger in rendering size than the original subtitle track.

You’re now done! I wanted to watch the video on a TV though. If you want to do that too, or play it on some other device, then:

  1. Transcode dn-01-modified.mkv with some video transcoding program, using the appropriate settings for your targeted device. (Do not forget to tell the program to burn in the newly added subtitle track into the video itself, if your targeted device cannot play ASS subtitles!) In my case, I used HandBrakeCLI with the settings below for use on a Samsung 60" TV. Note that I am burning in the subtitle, since my TV doesn’t like ASS subtitles.

    HandBrakeCLI -e x264 -q 20.0 -a 1 -E ffac3 -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mkv --loose-anamorphic --modulus 2 -m --x264-preset veryfast --h264-profile main --h264-level 4.0 --subtitle "2" --subtitle-burned 2 -i dn-01-modified.mkv -o dn-01-modified-burned.mkv
    
  2. Play the transcoded file dn-01-modified-burned.mkv on the targeted device.


As I said in the beginning: this is not an optimal process. Things can be done better, but I do not have the time to refine this process as of now. It would also be not-so-fun to do this for a large number of videos; it would get really repetitive. Luckily for me, I only had to do this for a few videos, but in the future, I’ll surely have more videos whose subtitle has to be enlarged, and by then, I’ll write a bash or python script to do everything automatically.

Share:
14,158

Related videos on Youtube

Laxask
Author by

Laxask

Updated on September 18, 2022

Comments

  • Laxask
    Laxask over 1 year

    I have some MKV files that have Advanced SubStation Alpha (ASS) subtitles in them. The subtitles are “toggleable”, so they probably aren’t “burned in” then.

    My goal is to—somehow—increase the font size of these subtitles. The best thing would be to directly modify the subtitle stream properties (if that even makes sense?) inside the MKV file. (Media player settings regarding font size won’t help; I will playback these MKV files on my TV.) This would later on make my HandBrake transcoding easier, since that program can’t import any other subtitle format except SRT. It can, however, use ASS subtitles if they are embedded within the file to be transcoded. That’s why the easiest way would be to preserve—directly modify—the subtitles within the MKV.

    But I don’t even know where to start with all this...

  • stib
    stib almost 10 years
    You could do something like
  • stib
    stib almost 10 years
    Curse the 5 minute edit limit! AIWS: You could do something like for i in *.ass; do sed "s/\(^Style:[^,]*,[^,]*,\)[0-9]*\(,.*\)/\154\2/"<"$i" >"${i/.ass/_modified.ass}; done The ugly regex replaces the third comma separated field after the word "Style:". Awk might be better at it, but my awk skills aren't up to much.