subtitle2pgm (1)
NAME
subtitle2pgm - Convert a subtitle stream to pgm images.
SYNTAX
subtitle2pgm [-i <filename>]
[-o <basename>]
[-c <c0,c1,c2,c3>]
[-g <format>]
[-t <format>]
[-l <seconds>]
[-C <border>]
[-e <hh:mm:ss,n>]
[-v]
[-P]
DESCRIPTION
subtitle2pgm converts a subtitle stream to pgm images,
(see: pgm(5)).
The subtitle stream is produced by
tcextract(1), e.g.
tcextract -x ps1 -t vob -a 0x20 -i file.vob
and are piped directly into subtitle2pgm, e.g.
tcextract -x ps1 -t vob -a 0x20 -i file.vob | subtitle2pgm
If the subtitle stream already exists as a file,
use the -i option to read from it, e.g.
subtitle2pgm -i subtitle_stream.ps1
OPTIONS
- -i <filename> Use <filename> for input instead of stdin.
- -o <name> Use <name> as the basename for output files. If no <name> was given, it defaults to "movie_subtitle". Output file names are of the form nameXXXX.pgm where XXXX is a title number. Caution: existing files will be overwritten without warning.
- -c <c0,c1,c2,c3> Override the default grey levels in output image. Default is 255,255,0,255. Valid values are in the range 0<=c<=255 where 0 is black and 255 white.
-
-g <format>
Set output image format, where format is a number from 0 to 5.
0 PGM (default)
1 PPM
2 PGM.GZ
3 PNG_GRAY (simple gray image)
4 PNG_GRAY_ALPHA (gray image with alpha channel)
5 PNG_RGAB (8 bit RGB + alpha channel).
PPM and PGM.GZ output won't work unless the program was compiled with support for it. -g 2 is recommended to save disk space. -
-t <format>
Set the output format, where format is a number from 0 to 1.
0 (default) srtx-files used by srttool (see README.srttool)
1 XML file format usable by DVDauthor ( dvdauthor.sourceforge.net ).
- -l <seconds> Add <seconds> to PTS (Presentation Time Stamp) for every DVD-9 layer skip (default 0.0). The internal PTS in VOB files is reset to 0 when a new layer is started. This is already handled by tcextract and should not be noticeable in subtitle2pgm. If for some reason the timing is misadjusted after a layer skip, try adding an appropriate offset with this option.
- -C <border> Reduce border around the text to <border> pixels. Many DVDs come with full screen subtitles where only a tiny part is really covered with text. Thus saving only the interesting part of the image saves space on your hard disk. Default: Don't crop. Usually this option is used with a small value for <border> e.g. -C 0.
- -e <hh:mm:ss,n> Extract only n subtitles starting from the time stamp hh:mm:ss. This gives a preview of what the subtitles would look like. E.g. -e 00:05:00,10 skips the first 5 minutes then outputs the next 10 subtitles.
- -v Enables more output messages that usually aren't needed.
-
-P
Write a progress report to show the program is doing something useful.
EXAMPLES
Suppose the current directory is a mounted DVD of "Foo", or contains the VOB
files from the DVD.
# change these as needed
MOVIE="Foo" # name of movie
TITLENO=1 # subtitle language number
VOBSET="`echo VTS_01_[0-9].VOB`" # not all movies start at '0'
# make 'pgm' files of the subtitles
cat $VOBSET | tcextract -x ps1 -t vob -a 0x2$TITLENO | subtitle2pgm -o "$MOVIE"
# Use OCR to convert them to text, (imperfectly)
pgm2txt -f en "$MOVIE"
# make a '.srt' file of it.
srttool -s -i "$MOVIE".srtx -o "$MOVIE".srt
The result is usually over a thousand '.pgm' and '.pgm.txt' files,
plus the desired '.srt' file. The '.srt' file will only be as good
as the OCR, so expect errors.
View the resulting '.srt' over the movie, in a large antialiased yellow font:
mplayer -sub "$MOVIE".srt $VOBSET -ass -ass-color ffff0000 -ass-border-color 00000000 -ass-font-scale 1.8 -fontconfig -font Verdana
AUTHOR
Arne Driescher, with tweaks and examples by A. Costa.