How to Add Text Effects and Unicode Characters to MPEG-4 Subtitles
It has been an ongoing and frustrating problem for me to find a way to create satisfying, professional looking subtitles that will display with MPEG-4 files (DivX, XviD, etc) watched on a standalone DVD player - that is, subtitles with fully-formatted text effects, such as bold, italics, colours and, especially, Unicode characters (specifically, musical note symbols to signify song lyrics in the subtitles) - just like those of professionally-authored DVDs. It's taken many months of perusing dozens of forum threads, and much trial and error, but I've finally figured out a fairly simple and effective way to do it.
Dealing with Unicode text subtitles is thorny. Compatibility issues between various programs are hard to deal with, in no small part because different programs that can handle Unicode text files save them in different ways - which then makes them unreadable in many other programs, even those that are Unicode compatible. This guide will try to describe these incompatibilities - and workarounds for them. I hope it doesn't put readers on the edge of tearing their hair out.
As you probably know, the standard way to watch subtitles with MPEG-4 files is to place separate, specifically-named subtitle text files into the same folder with the video file. This method works for both software media players (when the standalone subtitle decoder DirectVobSub has been installed and set to load automatically when MPEG-4 files are opened) and for DivX-capable hardware DVD players. The advantages to this method include selectability (the subtitles can be turned on or off), variety (multiple subtitles, in different languages, can be included with any video title) and flexibility (the files are easily updateable and replaceable).
The major disadvantages to using separate subtitle text files on standalone DVD players (there are no major drawbacks for software players, other than keeping track of the separate files) are ugliness and lack of readability (you're stuck with whatever font and display capabilities are built into your player's firmware, which are usually pretty meagre) - and a total lack of graphical formatting. I can't speak for all brands of DVD players but, after using two Apex models, an Avayon and, now, an LG DVB418, I am tired of watching subtitled MPEG-4s where control codes, such as "i" and "/i", are displayed on the screen instead of actual italicized text (because the subtitle file has been prepared with control codes that DirectVobSub can interpret). Also, none of these players will handle a subtitle text file that's been saved as Unicode (if you've ever had an .srt file that would not display any subtitles on your DVD player, it's probably because the file was saved in Unicode format - use WordPad or a similar text editor to re-save the file in standard, plain text (ANSI) format and it will probably work fine).
The only alternative for standalone DVD players is to burn permanent subtitles onto the video file, after the subs have been finalized with all the formatting enhancements you want. This presents disadvantages that are the flip side of the advantages mentioned above: the subtitles will not be removable via remote control (or any other way), they will be restricted to one language per video file and, if you catch a mistake on screen (a typo, misspelling, etc), you're stuck with it unless you do everything all over again (you can't just edit a text file and re-burn the CD or DVD). One more, even greater disadvantage exists: Unless you have access to the original source materials, you will be re-encoding an already-compressed MPEG-4 file - leading to at least a small amount of degradation in the quality of the video.
So, after weighing all these advantages and disadvantages, if you still wish to create more professional looking, formatted subtitles for your MPEG-4s, you can proceed with this guide.
If you have no standalone DVD player for your DivX files and only want to spiff up your subtitles for viewing on your computer, you can create new, formatted files, as described in Step 1, and stop there. They will remain separate text files and you will experience none of the disadvantages of hard coding the subs permanently onto your videos.
[Windows PC assumed; Mac OS or Linux users will have to find appropriate substitutes]
- A subtitle text file (.ssa - or .srt, .sub or any other format that can be converted to .ssa)
- Windows WordPad (or comparable, non-destructive, Unicode-compatible text editor)
- SubResync and SubMux (included with VobSub - be sure to install these optional utilities)
- VirtualDub or VirtualDubMod (using MaestroSBT's subtitle filter - or Subtitler if not using MSBT)
- Subtitle Workshop (optional - for adding line-specific formatting to subs - or use a text editor)
- Sub Station Alpha (optional - for adding line-specific formatting to subs - or use a text editor)
- MaestroSBT (optional - for adding overall formatting to subs - easier than SubResync or SSA - or use a text editor)
Step 1. Add formatting to a subtitle text file:
First, you need a subtitle file. Normally you will have downloaded one (creating subtitles from scratch is beyond the scope of this guide). If it doesn’t have the formatting you want, you can edit it. If it's already in SSA (Sub Station Alpha) format, all you need do is edit its contents. If it's a .sub, .srt, .txt or other form of subtitle text file, an additional step will be necessary to convert it to SSA format before editing:
1a: Converting the subtitle file to SSA format:
If your subtitle file is not already in Sub Station Alpha format (with an ".ssa" file extension), use SubResync to convert the file. Load your subtitle file into SubResync, then click "Save As...":
If you're going to be adding Unicode characters to the subtitles at any point, check the "Unicode output" box. Choose "Sub Station Alpha (*.ssa)" from the "Save as type:" list and - important - type the correct file extension in the "File Name:" box (change any other extension currently shown after the period to "ssa" - because SubResync fails to update the file extension shown there when you choose another file type for saving).
1b: Editing the subtitle file:
This is where it gets tricky.
If you're planning to add any special Unicode characters to your subtitles, the least complicated, although hardest to edit, method is Windows' WordPad (a confusing statement, I know). WordPad presents you with a flat, plain text file, where all the subtitles are surrounded by formatting codes and difficult to read. Finding the right subtitle to edit will be a chore, but WordPad is the only program I've found that creates Unicode output that's compatible with all the other programs you may need to use before you're finished. Use any other method and you're likely to wind up with a subtitle file that won't open in other programs.
Here are three popular alternative subtitle editing methods that are easier to use or more full-featured, but have drawbacks:
1) Subtitle Workshop (no Unicode support; full text support; no style support - good for editing subtitles that contain no Unicode and are not going to be burned permanently on the video): An excellent, full-featured editing program for text subtitles, too extensive to describe here (not difficult or complicated, just extensive). You can install the program and work with it a little to find out how to add formatting, like bold and italics, to text subs. Unicode characters would have to be added separately, later, in WordPad, and styles (for hard coding onto video) would have to be added later with MaestroSBT (both described below). Using such a three-step process is probably the best overall solution if you're not comfortable editing your subtitles manually using SSA syntax (as shown in the screen shot above). Just make sure you did not save your subtitle file with Unicode encoding when you converted it to SSA format in Step 1a (or else, re-save it with the Unicode box unchecked) before you try to load the file in Subtitle Workshop. You can save it again to Unicode later, in WordPad, if need be.
2) Substation Alpha itself (faulty Unicode support; full text support; full style support - good for editing subtitles that contain no Unicode and may be burned permanently on the video): An orphaned program (no longer developed) with all sorts of arcane procedures. Unicode characters would have to be added separately, later, in WordPad. Complex usage, difficult for newbies - recommended only for already-experienced users. It also, bizarrely, will load Unicode-saved files but not display the Unicode characters in them - and misreads the formatting codes in Unicode files as subtitle text (corrupting the input - which means it will probably corrupt the output when you save the file - so don’t try to load Unicode-saved files into this program).
3) SubResync (full but problematic Unicode support; full text support; full style support - good for editing subtitles that contain Unicode (extra steps involved to maintain compatibility) and may be burned permanently on video). If you're already familiar with SSA syntax and style commands, you can do all your editing of the subtitle file directly in VobSub's SubResync (note that, regardless of which file format you load into SubResync, all editing tags are immediately converted to SSA format - as shown in the second screen shot below).
As you can see, formatting tags are quite different than those used in standard SubRip (.srt) files: All formatting codes are escaped with backslashes and are enclosed in curly braces rather than angle brackets. The top portion of the Edit dialog handles text formatting, while the remaining part controls style formatting. If you select a particular subtitle from the main window, changes made in the Edit dialog will affect that subtitle only; if you deselect the individual subtitle in the main window (so that no subtitles are selected), then the top (Text) section of the Edit dialog will be greyed out (uneditable) and any changes you make to the bottom (Style) section will apply to all subtitles in the file.
If you're going to be editing styles (only necessary if you're burning the subs permanently on the video) and you're comfortable with the options shown in the dialog above, set your styles directly with SubResync. For newbies, though, the better choice would be MaestroSBT (see below) - primarily because it lets you preview your subtitles before saving them.
Step 2. Add special Unicode characters, if any:
When you're ready to start looking for special Unicode characters to put in your subtitles, open Windows' Character Map (Start > All Programs > Accessories > System Tools > Character Map) ...
Copy and paste the character(s) you want into your subtitle text (besides the musical note character, you can see there are other usable symbols, such as card suits, astrological signs, etc).
If you’re editing your subtitles with SubResync, you can continue using it to insert Unicode characters into the text, but there are a couple of hitches: The file must already have been saved in Unicode format before the program will accept Unicode characters as input (if you haven't done so already, you must open the file in SubResync, save it with the "Unicode output" box checked, then re-open the file) - plus, if you are going to permanently burn your subtitles on the video, you will have to save the file again using Windows' WordPad because, for some reason, other subtitle programs don't like the kind of Unicode used by SubResync and will not open Unicode files it has saved. They will, however, open files saved in Unicode by WordPad (just make sure you choose "Unicode Text Document" in the "Save As Type:" box when you save the file in WordPad; otherwise, you'll lose all the special Unicode characters that you've entered). I told you this could make you want to pull your hair out!
In SubResync, double-click on a particular subtitle to open the Subtitle Style Editor for that subtitle, paste your Unicode characters in the text area at the top and click "OK." When you've finished all your editing, choose "Save As..." from the main window and make sure the "Unicode output" box is checked before saving the file.
Better yet, If you're comfortable wading through your subtitle file in flat text format, it's easier to just add your special Unicode characters in Windows' WordPad itself. As long as you remember to save it as Unicode, the file should be fully compatible with any other program that can handle Unicode text:
Enter your special Unicode characters in the desired places in the text, then save the file, making sure to choose "Unicode Text Document (*.txt)" from the "Save as type:" combo box - and also change the file extension back to "ssa" before clicking "Save" (WordPad will change the file's extension to "txt" when you make a selection in the "Save as type" box, so just re-type the correct extension in its place).
You should now have a fully-formatted SSA subtitle file. Put this file in the same folder as the video it references (making sure to name the subtitle file to the same name as the video file, save for the extension, of course) and you can watch the video with subtitles in any media player on your computer, providing DirectVobSub is installed:
(Hint: You can keep multiple subtitle files, in different languages, in the same folder by inserting a language code into the subtitle filename, between the name and the extension - i.e., “Movie.en.ssa," "Movie.fr.ssa," "Movie.es.ssa," etc - note, the abbreviations are language-specific, in that “es” (Español), not “sp,” stands for Spanish.)
If this is sufficient for your needs, stop here ... or continue on to either mux or burn the subtitles into the video file so that separate subtitle files do not have to be maintained. Multiple subtitle files can be muxed into a single MPEG-4 container, but remember that such files can only be watched, with subtitles visible, on your computer; the subtitles will not show up on your TV, using a standalone DVD player (for that, you need to burn a single subtitle file onto the video).
Step 3. Mux the subtitles or burn them onto the video file:
3a. Multiplexing (muxing) the subtitles:
The only real advantage to muxing your subtitles is to eliminate the separate subtitle files that have to be kept track of separately from the video file, but those separate files are necessary if you're going to watch the videos on your DVD player without burning subtitles onto the video.
Multiplexers such as AVI-Mux GUI and VobSub's SubMux only mux text subtitles into an MPEG-4 container (.avi, .mkv, .mp4, etc). They will not mux graphic (bitmap-rendered) subtitles like those ripped from DVDs in VobSub format. This guide doesn’t deal with DVD subtitles, but there are lots of other guides on this site that will help you rip and convert DVD subs.
(Hint: If you’ve wound up with VobSub-format subtitles (they come in two files, one with a .sub extension and the other with an .idx extension), you can burn them directly onto an MPEG-4 video using VirtualDub with VobSub’s own subtitle filter, but they’re usually (or always?) just plain text, devoid of any formatting, and you can’t edit them. For that, you’ll have to convert them to SSA text format using SubResync - and a lot of tedious OCR character recognition. Try to find an .srt or .ssa version of the same subtitle file if you can.)
If your subtitles are saved as Unicode, mux them with SubMux [AVI-Mux GUI thinks Unicode SSA files are audio (!) tracks and insists on muxing them into an .mkv (Matroska) container instead of an .avi one - which then (logically) will not display the misidentified subtitle track at all]. SubMux is thoroughly self explanatory:
Non-Unicode subs can also be muxed with AVI-Mux GUI, if you're already used to using it (it's more complex than SubMux and won't be described here).
If all you're striving for is an MPEG-4 video with self-contained subtitles you can watch on your computer, you're done! If, on the other hand, you desire a finished video you can burn to disc and watch with formatted subtitles on a standalone DVD player, skip this step (muxing) altogether and continue with the next steps to re-encode your video with permanent subtitles.
3b. Setting the style of permanent subtitles:
When watching multiplexed videos on your computer, the subs are generated from plain text files and the style of the subtitles (font, size, placement) is controlled by DirectVobSub, just as it is when watching subtitles stored in separate text files (you use DirectVobSub's options to adjust the way the subtitles are displayed on your screen). Conversely, when watching a video with hard-coded subtitles, the styles must be applied before they're encoded onto the video stream.
Subtitle Workshop applies no styles to its output files so, if you don’t add some style tweaks to them before burning them on your video, they will display very plainly; SubResync lets you define a style for the subtitle file (as described above), but requires entering manual commands and provides no preview of its output. If you want precise control over the way your subtitles look and want to preview them before encoding, that's where MaestroSBT come in - it works by setting options in a series of dialog boxes that are opened by choosing from a row of buttons on the right side of the program:
It's fairly easy and intuitive. The best way to show how to use the program is to just show its pertinent dialog screens in succession:
Set Files (not applicable unless creating DVD subs): For MPEG-4 subtitles, no files will be generated here, so you can leave the default file specifications as they are.
Most of these options can be left as is, except to set the horizontal and vertical size parameters to match the dimensions of the video file on which you're laying the subtitles. "16:9 correction" will squeeze the subtitles' letters together if your video is anamorphically encoded; "4:3 correction" (in the same option where it says "No correction," above) will spread them apart. You can play with these and other options, using the program's "Edit & Preview" button, to see what differences they make. [Note: This paragraph has been updated since first posted, as it seems the Multibyte Code Page setting can be left as is, at "System default," instead of needing to change it to "UTF-8," with Unicode symbols displaying correctly (in my output, anyway) using either setting.]
Timing: Set the values to the same frame rate as the video file.
Segments (not applicable unless using multiple input files or chapters)
Normally, you want single-line subtitles to align with the bottom line of double-line subtitles; if so, make sure to change the option at the top to "Subtitle" and correct "Bottom Margin" to a number that represents the number of pixels from the bottom of the screen on which you want your subtitles aligned (for some reason, the program defaults to the opposite, which will make single-line subtitles align with the top line of double-line subtitles - yucch!). Not all fonts will display Unicode characters so, if your Unicode symbols do not show up, try another font (in my version of Windows, Arial and several fancy fonts, like Century Gothic, do display the Unicode text but, surprisingly, Tahoma does not). Again, use the "Edit & Preview" button on the main window to see how your changes will look.
3c. Re-encoding the video file with permanent subtitles:
To lay a single subtitle stream permanently over a video stream, the video file must be re-encoded with the subtitles. One of the most common programs for encoding MPEG-4 videos is VirtualDub (in all cases here, VirtualDub will be used to refer to either VirtualDub or VirtualDubMod, a slightly more full-featured sub-development of VirtualDub but seldom updated anymore - use whichever program you prefer).
If you did not use MaestroSBT in the last step, you can use Avery Lee's Subtitler plug-in for VirtualDub (see the “Resources needed” section, above, for the download link) to encode your subtitles; otherwise, MaestroSBT itself will serve the subs to your video file in VirtualDub. In either case, remember to copy the ".vdf" filter file, supplied with either program, into VirtualDub's "plugins" folder (usually "C:\Program Files\VirtualDub\plugins") before you start this step.
To use MaestroSBT, open your desired SSA subtitle file in MaestroSBT and click on the program's "Edit & Preview" button (the above is only a partial screen shot of the very large window that opens when you do so). Click on the mysterious, unnamed icon under the "Guidelines" button to start feeding the subtitle data to VirtualDub. The following window will appear:
Nothing needs to be changed unless you want to start the subtitles at some location other than the beginning of the video. It's best not to check "Don't check frame rate match" or your subtitles will likely be out of sync by the end of the video (if you get an error message about the frame rate, go back and correct the frame rate you entered in MaestroSBT's “Timing” options). Move the above window to the a place on your screen where it won't become hidden by other windows (at least the first time you do this, to make sure it works), and let it sit there while you ...
Open VirtualDub, load your video file and set all the options you require to encode it (which are beyond the scope of this guide - but
don't forget to choose a Compression filter from the Video menu, such as DivX or XviD). Finally, click on the Video menu, as highlighted, and choose "Filters...".
In the "Filters..." dialog, click "Add..." and choose the subtitle filter you want to use.
If you're feeding the subtitles through MaestroSBT, as described above, choose the "MSBT subtitler 1.0" filter and click OK. Click OK again on the "Filters..." dialog to close it. Back in VirtualDub's main window, hit your keyboard's F5
key to refresh the loaded files. The "Feeding VirtualDub plugin" window that appeared when you started feeding the subtitles from MaestroSBT should now disappear from your screen and you should be able to scroll through the video file, using VirtualDub's seek bar, and see your subtitles superimposed on the video output pane on the right (you can also type F5 to refresh the subtitles, without reloading them, any time you make any changes to them in MaestroSBT):
If you're not using MaestroSBT to feed your subtitles, and you've copied Avery Lee's filter into the VirtualDub "plugins" folder, you can instead choose the filter named, simply, "subtitler" from the list in VirtualDub's "Filters..." dialog. You will be asked to enter a file name for your SSA subtitle file, after which your subtitles should, likewise, appear in VirtualDub's output pane.
Proceed to re-encode the video to a new file. You should now be able to watch it on your computer or on your standalone DVD player and see fully-formatted subtitles superimposed on the video.
That's about it. If anything is unclear, feel free to leave questions in this thread, if still open, or elsewhere in the forum.
+ Reply to Thread
Results 1 to 10 of 10
Last edited by PBear; 28th Apr 2010 at 16:18.
That is awesome, PBear! Thanks for all the time you put into that.
I've spent days trying to correct my text encoding through VirtualDub filters, Aegisub, etc. & all I had to do was change to unicode in Wordpad! Yes, I am a walking, talking dork but your article got the right neurone working.
Glad to know it's been useful to someone. Thanks for the feedback.
Great tutorial !
I use it after edit my subtitles in Visuasubsync.
I insert a # symbol in Visualsubsync and then, at the end, convert .srt sub with subresync and finally save with Wordpad.
A little intricate, but working like a charm !
Thanks, PBear !
And not all of our write a line when find a tutorial intersting.
I think your tutorial is useful to many friend, only... a little "idle".
I am new to this forum.
I have an mp4 file and a srt subtitle file which is filled with Unicode characters(It is a Persian Subtitle).
I Combined them together with MKV MERGE. the Unicode character are displaying correctly. but there is a problem! the output file is an mkv file and I want my Output file to be MP4 to play on iPad 2.
can some one help?
Mp4box,looks like it doesn't support Unicode.
I searched with google about hard subs and soft subs. I learned what they mean. looks like iPad doesn't support soft-subs. I am going to test thishttps://www.videohelp.com/tools/HandBrake
Last edited by Ardalan47; 15th Sep 2012 at 12:00.
Any Ideas? I Checked some guides but each of them tell something different
Ardalan47 - Next time just make a new post. Do NOT post in guide threads we have. This is why I wish the moderators would lock guide threads.
Try using Xvid4PSP to hard code your subtitles. It works correctly with Unicode subtitles. I have used it to hardcode Chinese subtitles for a friend. Handbrake has a lot of problems with subtitles and I suggest using Xvid4PSP instead.