View Single Post
Old 20th April 2009, 15:16   #1  |  Link
Ulf
Registered User
 
Join Date: Sep 2008
Location: Sweden
Posts: 66
MaestroBDSubs - Creating high quality Blu-ray subtitles

Introduction

With both BDSupEdit and BDSup2Sub supporting BDN XML import and SUP creation, I'll share my tools for creating high quality BD subtitles. The programming language is PostScript (!) and the tools are in the form of Windows batch files. The tools don't render any bitmaps with subtitles, but are using MaestroSBT for this task. The tools create BDN XML file + PNG files for Scenarist import which now can be converted to a BD SUP file by BDSupEdit or BDSup2Sub. MaestroSBT is really intended for DVD subtitle creation (4-bit bitmaps). By creating oversized bitmaps that are scaled down, we'll achieve nice looking antialiased subtitle bitmaps.

A short description of the tools:

SRT_to_SSA-BR.bat - Converts an SRT subtitle file to an SSA file for MaestroSBT input
MaestroBRSubs.bat - Converts output from MaestroSBT to BDN XML file and 8-bit PNG's (trimmed with alpha transparency)
test_AVS_BDN.bat - Displays an AVS file (1080p, 1440x1080, 720p, 576i or 480i) with one selected subtitle overlayed the clip (just as it will look in the end), and tests alternate X/Y adjustments for the subtitles.
modify_XML_from_SRT.bat - Sets new timings in a BDN XML file from timings in a SRT file
modify_XML_XY_position.bat - Modifies position of the subtitle bitmaps in the BDN XML file
XML_PNG_to_SUP.bat - Converts BDN XML file + PNG's to SUP
INI_PATH.BAT - example file specifying the path's to the executables the batch files are using (see below)

Download

See attachment MaestroBRSubs_v1_0.zip
MaestroBRSubs_v1_0.zip

Programs used in the batch files:

GPL GhostScript - Postscript interpreter (ver 8.63) , http://sourceforge.net/project/showf...?group_id=1897
ImageMagick (Q8 version) - bitmap image manipulation, http://www.imagemagick.org
(Q8 version is much faster than Q16)
Virtualdub - video processing application, http://sourceforge.net/project/showf...?group_id=9649
BDSup2Sub - BDN XML to SUP conversion - http://forum.doom9.org/showthread.php?t=145277

You'll also need MaestroSBT:

MaestroSBT - subtitle BMP generation, http://sourceforge.net/projects/maestrosbt/

Preparations before using the batch files:

There are two ways of specifying the path's to the executables for the batch files (the second one is the recommended).
1. Edit each .BAT file and specify the path's.
2. Create one file with all path's specified (called by each of the batch files). All the batch files are looking for the file %ALLUSERSPROFILE%\INI_PATH.bat. This usually translates to C:\Documents and Settings\All Users\INI_PATH.BAT (write %ALLUSERSPROFILE% in an explorer window). Look in the zip file for an example of "INI_PATH.BAT".

Description of the tools in more detail:

SRT_to_SSA-BR.bat
Converts an SRT subtitle file to an SSA file for MaestroSBT input. Just drop SRT file(s) in the batch file and specify frame rate. The SSA file has four different styles predefined:
Style1 - Style4. Look in the batch file for more information on the styles. Default settings of font, font size, default style etc can be changed in the batch file. Bottom/top/left margins are not important to set other than the defaults. The tool modify_XML_XY_position.bat allows you to change these afterwards.
SRT_to_SSA-BR.bat is looking for a file SRT_to_SSA-BR.ini in the same folder as the SRT file(s) and calls it as a batch file if found. If for example, the SRT_to_SSA-BR.ini contains the lines:

set FONT=Tahoma
set FONTSIZE=90
set OUTLINE=4
set LINESPACE=110
set BOLD=1

this will override the corresponding settings in SRT_to_SSA-BR.bat.
SRT_to_SSA-BR.bat will create a folder with the same name as the SRT file (without the .SRT suffix). When opening the SSA file in MaestroSBT it's just to click on the button "Generate". MastroSBT will create BMP's and a SST file containing in/out times in the same format as expected in a BDN XML file. Note that MastroSBT is slow, especially for the large bitmaps we are demanding.

MaestroBRSubs.bat
Drop folder(s) with BMP's/SST in the batch file. You specify to what format the bitmaps are to be scaled (1080p, 720p, 576i or 480i), the frame rate and if you want the subtitles to be centered (good if you have left adjusted subs that you'll want centered). MaestroBRSubs.bat creates a file "BATCH.BAT" that actually does the scaling, trimming etc when executed. The end result is a BDN XML file and 8-bit trimmed PNG's with alpha transparency. These are good for Scenarist HDMV, BDSupEdit or BDSup2Sub import.
MaestroBRSubs.bat contains default settings of the font and anti-alias color (you can change these by editing the batch file).

test_AVS_BDN.bat

Move our AVS file (1080p, 1440x1080, 720p, 576i or 480i) to the same folder containing the folder with BDN XML/PNG's. Mark the AVS file and the subtitle folder and drop them both in the batch file. This will display the AVS clip with one subtitle overlayed the clip. Various X/Y displacements of the subtitles can be tested.

modify_XML_XY_position.bat
Drop BDN XML file to modify horizontal and vertical position of the subtitles. For vertical positioning, sub- and top titles can be modified separately (if you move a subtitle 20 pixels up you'll probably want to move the top titles 20 pixels down).

modify_XML_from_SRT.bat
If you need to change the timings of the subtitles after the subtitles has been converted to BDN XML + PNG's, the batch file provides an easy way to do this. Put the SRT with the new timings in the same folder as the XML file. Drop both of them in the batch file and a new XML file is created.

XML_PNG_to_SUP.bat

Drop folder with BDN XML/PNG's in the batch file for conversion to SUP file by BDSup2Sub.

Technical details


What MaestroBRSubs.bat does:
1. Modifies the BMP's palette to preferred font and anti-alias colors and sets the background to red.
2. Scales and trims the bitmaps with the help of ImageMagick. The dimensions of the bitmaps and the trimming coordinates are extracted from the PNG files.
3. A PostScript program reads the Palette from a PNG and creates a new B/W palette and a tRNS chunk (transparency) based on the red content in the palette. Calculation of crc-32 checksums for the new PNG chunks are made in PostScript.
4. A PostScript program creates the BDN/XML file based on data from the SST file and PNG's.

For an example of a SUP created by these tools, take a look at the attachment to post #16 here.

Last edited by Ulf; 20th April 2009 at 15:23.
Ulf is offline   Reply With Quote