PDA

View Full Version : [all variants] HOWTO create SRT subtitles from VOB files


bernardfrancois
August 30th, 2009, 11:22 AM
FIRST METHOD:

Use the ksubtitleripper package from synaptic.

SECOND METHOD:

If ksubtitleripper doesn't work for you, or you dont want to use it you can follow these steps:

Install the subtitleripper package from synaptic.
Change your working directory to the directory containing the VOB files. These files should not be encrypted.
Copy and paste the script below into a terminal window.



# NOTE: this script assumes there are no more than 9 subtitle tracks
# creates subtitle files for the 9 first languages
for lang in {0..9} ; do
(
# extract the given language and creates a subtitle file
tccat -i *.VOB | tcextract -x ps1 -t vob -a 0x2$lang > subs-$lang ;

# converts the subtitle file to an .srt file (if the file isn't empty)
if [[ -s subs-$lang ]] ; then

(
# convert the subtitle frames to seperate images
echo "LANGUAGE $lang: WILL NOW CREATE SUBTITLE FRAME IMAGES" ;
mkdir pgm-$lang ;
subtitle2pgm -o pgm-$lang/pgm-$lang- < subs-$lang ;

# use gocr to convert the subtitle frames to text
echo "LANGUAGE $lang: WILL START OCR ON SUBTITLE FRAME IMAGES" ;
pgm2txt pgm-$lang/pgm-$lang- ;

#convert the text to a .srt file
echo "LANGUAGE $lang: WILL NOW CONVERT THE TEXT TO AN SRT FILE" ;
srttool -s -w < pgm-$lang/pgm-$lang-.srtx > subs-$lang.srt ;
) ;

else
# removes the empty subtitle file (a languages that wasn't available)
rm subs-$lang ;
fi
) ;
done


Notes:

ksubtitleripper didn't work for me. I reported a bug regarding the issues I had with it:
https://bugs.launchpad.net/ubuntu/+source/ksubtitleripper/+bug/421470
Depending on the actual subtitles you want to copy, you may have to be the copyright holder of the subtitles.
Use this script at your own risk.
Feel free to ask any questions about the script, or to send me a personal message in case it would be broken.

Note that

legatek
September 10th, 2009, 01:51 AM
LANGUAGE 0: WILL NOW CREATE SUBTITLE FRAME IMAGES
LANGUAGE 0: WILL START OCR ON SUBTITLE FRAME IMAGES
Using /usr/share/subtitleripper/gocrfilter_none.sed to filter gocr output
creating directory ./db/
creating empty file ./db//db.lst
File pgm-0/pgm-0-*.pgm not found
File pgm-0/pgm-0-*.pgm.gz not found
LANGUAGE 0: WILL NOW CONVERT THE TEXT TO AN SRT FILE
/home/monkey/subtitle-extract.sh: line 23: ../../subs-0.srt: Permission denied

legatek
September 10th, 2009, 02:44 AM
I tried on another movie, and this was the console output:

LANGUAGE 0: WILL NOW CREATE SUBTITLE FRAME IMAGES
LANGUAGE 0: WILL START OCR ON SUBTITLE FRAME IMAGES
Using /usr/share/subtitleripper/gocrfilter_none.sed to filter gocr output
creating directory ./db/
creating empty file ./db//db.lst
File pgm-0/pgm-0-*.pgm not found
File pgm-0/pgm-0-*.pgm.gz not found
LANGUAGE 0: WILL NOW CONVERT THE TEXT TO AN SRT FILE
LANGUAGE 1: WILL NOW CREATE SUBTITLE FRAME IMAGES
LANGUAGE 1: WILL START OCR ON SUBTITLE FRAME IMAGES
Using /usr/share/subtitleripper/gocrfilter_none.sed to filter gocr output
File pgm-1/pgm-1-*.pgm not found
File pgm-1/pgm-1-*.pgm.gz not found
LANGUAGE 1: WILL NOW CONVERT THE TEXT TO AN SRT FILE

-----

db, pgm-0 and pgm-1 directories were created, and the pgm directories had files named pgm-0-.srtx and pgm-1-.srtx, respectively, both with size 0.

bernardfrancois
October 14th, 2009, 04:03 PM
Was this a VOB file from a commercial movie? Typically, those are encrypted. Probably my script doesn't work on encrypted VOB files.

If anyone tried with a non-encrypted VOB file, please let me know if it worked.