/*
sub2ppm  copyright 2005 Jan Panteltje.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/


This program uses the .sub output from vob2sub (part of submux-dvd)
to create a .ppml file and related .ppm pictures, so you can
use transcode subtitler or subtitler-yuv to make embedded subs
from a DVD .VOB.

The bitmaps are rendered into the output format, for example DivX.
This may be useful if subs need not be switched off, and OCR of
the bitmaps is not possible.

There is a -s slice level option, this sets what is transparent.
the default is 18 (on 0-255 grey levels), anything above this slice level
is visible, anything below it not.

sub2ppml uses the utility bmptoppm to convert the .bmp files that vob2sub
makes to .ppm files.

The default output file is out.ppml.
You can use thsi program with subtitler-yuv (it has mjpeg tools compatible output
format), or with transcode subtitler.


Example:
mount /dev/dvd /mnt

make one big vob from teh pieces of one set:
cat /mnt/video_ts/vts_01_1.vob /mnt/video_ts/vts_01_2.vob > big.vob

make sure the included palette.txt is in the current directory, it sets the sub colors.
vob2sub big.vob

This generates the subtitle bitmaps and a sub.sub file with timing and other info.

Here is where sub2ppml comes in:
sub2ppml -i sub.sub

This produces out.ppml, and a lot of .ppm picture files.
Now we can use transcode:

# pass 1
transcode \
-i big.vob \
-x vob \
-y divx4 \
-J subtitler="subtitle_file=out.ppml  color_depth=32" -V -Z 720x576 \
-o subs_embedded.avi \
-w 1550 \
-c 0-100000 \
-V \
-D -8 \
-R 1

# pass 2, with de-interlace
transcode \
-i big.vob \
-x vob \
-y divx4 \
-J subtitler="subtitle_file=out.ppml  color_depth=32" -V -Z 720x576 \
-o subs_embedded.avi \
-w 1550 \
-c 0-100000 \
-V \
-R 2 \
-D -8 \
-I 3


The D -8 is a delay, video early, that was needed in my case to get correct audio video sync.

Leave it overnight! transcode with subtitler is slow.

You can make a short test-run by setting -c 0-10000 for example,
you can also set
1 *main show_output=1
in the out.ppml for test.

play with
xine subs_embedded.avi
or
mplayer subs_embedded.avi

vob2sub allows you to select a subtitle channel.






