Mar 022016
 

(I write this article in total defiance of the idiots at the Motion Picture Association of America (MPAA) as well as Advanced Access Content System (AACS LA) for shutting down SlySoft, the makers of DVD and Blu-ray ripper AnyDVD HD, which as usual has been accused of being a pirating tool regardless of its beneficial uses. Unfortunately, that means that people like me who use it legitimately for ripping discs that are legally owned to put on personal devices or media servers end up getting caught in the wake.)

For over a year, I have been adding my DVD/Blu-ray library to my Plex server, including 3D titles that I’ve converted to side-by-side 3D. (No, I have been not been selling the discs afterward.) Unfortunately, one title in particular has proven to be problematic – my Dances With Wolves 20th Anniversary Blu-ray. Unlike most of my other discs, DWW includes forced subtitles for the Lakota and Pawnee languages; but none of the forced subtitles were displayed when playing the .mkv unless I displayed all of the subtitles. After doing some searching, I found out that I was not the only one in this predicament.

DVDs use a subtitle format that has come to be known somewhat inaccurately as VobSub because the subtitles are stored in the DVD’s .VOB files. (VobSub is actually a plugin for a popular editing and muxing tool called VirtualSub.)  When DVD subtitles come up on the screen, what you’re seeing is a graphical, not text-based, overlay. This is what allows the Irken language to be displayed as subtitles for the Invader Zim DVD set, for example. Most, maybe even all, media streamers know how to handle VobSub tracks.

Blu-rays, however, use a subtitle format called PGS or Presentation Graphic Stream. PGS is graphical as well but not many media streamers support forced subtitles within it. Often, your only options when playing back MKV files with PGS subtitles are to show all of the subtitles or none at all. (This is even more problematic with side-by-side 3D, but I’ll tackle that in a different article.)

Fortunately, with some research and trial-and-error, I’ve compiled the following steps to embed forced subtitles into your Blu-ray rips as VobSub instead of PGS so that you’ll always get the necessary subtitles on the screen.

What I’m about to show you can be done in several ways, possibly in reduced steps. I am simply showing you the method that I used. Feel free to experiment and make changes as you see fit.

Required Programs

Although I did my conversions in Windows 10, the method itself is platform-agnostic with the right tools.

  • A program to strip the AACS encryption from the Blu-ray
  • BDtoAVCHD or similar program that can embed forced-only subtitles into the initial .mkv file
  • MediaInfo or other tool to confirm stream information
  • The mkvtoolnix suite of programs that includes mkvextract and mkvtoolnix-gui
  • BDSup2Sub (Java-based, so you’ll need the latest version of Java Runtime Environment)
  • Handbrake and any associated packages

Converting To Initial MKV

Obviously, you need to strip the copy-protection from the Blu-ray first. I would have suggested AnyDVD HD, but seeing as how the MPAA and AACS LA have shown their ignorance once again, you’ll have to look for alternatives. (They are out there, but I won’t link to them here. Google is your friend.)

As much as I like Handbrake to do straight conversions of my disc rips, I find that BDtoAVCHD gives some extra options that are useful, especially if you don’t know if you have forced subtitles in your disc. In BDtoAVCHD, open the BD folder than contains the disc image. (If prompted to select a playlist, 00800.mpls is almost always the one you want for US/English.) When it’s loaded, click on Scan Bitrates and let it scan the image, which will take several minutes. As you can see in the results, two of the subtitle tracks have forced instances.

Scanning for forced subtitles

When scanning is done, click Close. Change the encoding settings to what you prefer. The image below shows the settings that I used for Dances With Wolves. Note that decreasing the CRF rate or changing Speed vs. Quality to anything slower than what is shown will increase the quality of the initial .mkv but will take longer to encode and possibly result in a much larger file. You should set these to be as slow as you can bear, but in general slower is better. Modify any other settings, including the output folder, click Add to Queue, click Start Jobs, then go do something else until it’s done.

BDtoAVCHD settings

Extracting and converting PGS subtitles

While not completely necessary, you can use MediaInfo to analyze the file. The file should only have one PGS track – the forced-only subtitle track.

MediaInfo results

(The next part can be tricky for those who have never worked with the command line. Sorry, but I can’t help that you’ve lived a Windows-only, GUI-based lifestyle. You’ll need to figure out the command line on your own before proceeding.)

On a command line, use mkvextract, which is part of mkvtoolnix, to extract the PGS substitle stream into a separate .sup file. In this case I called it “Dances With Wolves.sup”. The example below shows the command being run with mkvtoolnix installed in the directory above where the .mkv file is. You will have to change the path depending on where you installed mkvtoolnix in relation to the .mkv file. Files with embedded spaces in them must be enclosed in quotes or double quotes.

$ ../mkvtoolnix/mkvextract.exe tracks “Dances With Wolves.mkv” “2:Dances With Wolves.sup”
Extracting track 2 with the CodecID ‘S_HDMV/PGS’ to the file ‘Dances With Wolves.sup’. Container format: SUP
Progress: 100%

The key here is the 2: that precedes the .sup file. In this case, that represents the stream inside the .mkv file that contains the forced subtitles. You might have to experiment with this. If you select the wrong track, you will notice immediately. Accidentally choosing an audio stream will look like this…

Extracting track 1 with the CodecID ‘A_AC3’ to the file ‘Dances With Wolves.sup’. Container format: Dolby Digital (AC-3)

…whereas selecting a video stream will look like this:

Extracting track 0 with the CodecID ‘V_MPEG4/ISO/AVC’ to the file ‘Dances With Wolves.sup’. Container format: AVC/h.264 elementary stream

Once the .sup file has been created, open BDSup2Sub, click File → Load then select the .sup file that you created. Click OK to close the Conversion Options window. Click File → Export. The export file name should now end in .idx instead of sup. Click Save to write the new .idx and .sub files, then exit BDSup2Sub.

BDSup2Sub

Run mkvtoolnix-gui for the final muxing. In the Source Files area, right click and select Add Files. Add the .mkv file that you created at the start. Repeat for the .idx file that you created. In the Tracks, Chapters, tags, and attachments area on the bottom, uncheck HDMV PGS, The list of tracks should look similar to the following:

Mkv muxing

At the very bottom of the window, enter a filename for the new mkv file. This will not be your final file, so don’t name it what you want the final file to be. Click Start Muxing. Once muxing is finished, exit mkvtoolnix-gui.

Open Handbrake for the final conversion. Click Source → File and select the muxed .mkv file. Change the Destination File name to whatever you want. If this will go to a Plex server, it should be renamed to the title with the year in parentheses, such as “Dances With Wolves (1990).mkv”.

Select whatever options you feel are appropriate for the quality of the encoding that you want. I recommend the following:

Picture tab – Anamorphic: none, cropping: automatic, keep aspect ratio: checked

Filters – Everything off (Blu-rays are usually encoded in progressive format and don’t need any of the functions on this tab)

Video – Constant framerate, constant quality set to 20 (lower is better but slower), x264 preset to slow, H.264 profile to high, and H.264 level to 4.1. If you can deal with longer waits, set the constant quality and x264 presets as low and slow as possible. Do not set constant quality to anything lower than what you set for the initial .mkv file because you will get a bigger file with no benefit.

Audio – Set to whatever you want. I like to include the core DTS or AC3 soundtrack as a Dolby Prologic II mixdown track and a separate AC3 or DTS passthru track to allow for stereo or native surround playback.

Here’s the important part. In the Subtitles tab, click Add Track. If you followed this guide, the only one available should show as a VobSub track. If it shows up as PGS, make sure that you selected the muxed .mkv file that you just created, not the one that you created at the start. The track already contains the forced subtitles but they’re no longer flagged as “forced”; so leave that unchecked or you’ll get no subtitles at all. Check the Burn In option! When you’re done, the subtitle option should look like this:

Handbrake subtitle

Click Start and let it run. Depending on your hardware, the Handbrake quality selections, and the length of the movie, this can easily take several hours. Do this overnight if you need to use your system because Handbrake always sends my multi-core PCs to 100% CPU utilization.

The Results

Once the file is created, load it in VLC media player or your player of choice for a test. Alternately, transfer it over to your media server. Fast forward to a section that you know has subtitles and you should be able to see them. The screen shot below verifies that the text is embedded in the video stream — the subtitle track cannot be selected but the text is displayed. Success!

SuccessDances With Wolves ©1990 TIG Productions

Once again, do not do this for side-by-side or top-bottom 3D titles! The subtitles will be unreadable when watching the movie if you follow these steps. I already found tools that should correct this, so I will experiment with the 3D version of James Cameron’s Avatar, which also has forced subtitles, and will make another post when I figure that out.