Tovid Wiki

Convert PAL DVD to NTSC preserving subtitles

102pages on
this wiki
Add New Page
Add New Page Talk0

I just moved to California from Italy, and I had the problem to be able to play my PAL Star Trek DVDs on NTSC equipment. I decided to transcode and convert them, even if I've been told cheap multi-standard players and TV exist. I did not want anyway to buy a new player and/or annoy my friends when I visit them with one of my PAL DVDs.

The resuts are very good indeed. To be honest, I do not regret the quality I had with the "original" on a PAL system. No audio lag, no interlacing problems that I could see. Let me know if you have.

At the beginning I faced a number of problems, which I solved either writing small external scripts, downloading and installing some software, or patching tovid:

1) extracting the material from the original DVD 2) having tovid accept the video format and correctly encode the sound 3) muxing DVD-compliant subtitles (that can be turned on/off at will)

I decided not to replicate the original DVD menus. The original ones are often cumbersome and todisc' ones are just so cool. Additionally, by selecting which titles you want to encode in your DVD(5?) output, you will have space for higher bitrate of the transcoded material.

1) Extracting the DVD titles (and subtitles): I used a script like the following:

TITLES="2 3 4 5"
for i in $TITLES
        mplayer dvd://$i -dumpstream -dumpfile $i.dump
        mencoder $i.dump -o /dev/null -ovc copy -nosound -vobsubout $i -vobsuboutindex 0 -vobsuboutid en -sid 1&

the variable TITLES contains the title(s) you want to include in your DVD. In this implementation, the subtitles index and id are hardcoded to "0" and "en". Modify at your will. The script is "parallel" in the sense that it dumps from the DVD and, while it proceeds to the next title, it starts a process to extract subtitles from the dump already on the hard drive.

2) tovid "bugs" 2.1) As of version 0.31, I have found a couple of bugs while using tovid. First, my files were not recognized and the process aborted. Simply commenting the "check" in tovid slved the problem! I commented lines 1128 to 1130 (a complete patch with this and the other changes is attached below) 2.2) It seems there is a problem encoding ac3 audio. Be sure to have ffmpeg compiles with a52 support (see the relevant howto if you use a debian based distro (ubuntu etc)) *and* modify all the "-ac 2" options in tovid in "-ac 6" (I counted three substitutions, see also this discussion) 2.3) to incrase performance during the transcoding on my dual-core machine, I though it would be better to modify the line 1076 to:

MTHREAD="--multi-thread 3"

instead of only 2. Three processes running at the same time should keep the CPUs more busy especially while some process is waiting some I/O to occour.

3) Subtitles First, download and install It is a script that will convert the vobsub files into png suitable to be used with spumux (included in the dvdauthor package). Then, I added the following commands in tovid right after the transcoding: if the script finds the .idx and .sub files with the same basename of the encoded file, it will include them in the resulting output.

Starting at line 2982:

# Subtitles: if .idx and .sub files with same basename of the input file exist,
# mux them in the output file.
if [[ ( -e $IN_FILE_BASE.sub ) && ( -e $IN_FILE_BASE.idx ) ]]
       spumux -s0 $TMP_DIR/$OUTNAME-sub.xml <$OUT_FILENAME >$TMP_DIR/$OUTNAME.sub.mpg
       mv $TMP_DIR/$OUTNAME.sub.mpg $OUT_FILENAME

Finally with a standard command like:

todisc -noask -nowarn -files *.dump -titles "7.13" "7.14" "7.15" "7.16" -menu-title "DS9 s7" -out dvd

After this process I burned a DVD+RW disc:

makedvd -burn dvd/

and inserted it on a NTSC DVD + TV set. It played beautifully.

The diff -u patch against tovid v0.31 is here:

--- tovid	2007-08-18 12:24:38.000000000 -0700
+++ /usr/local/bin/tovid	2007-12-22 16:14:10.000000000 -0800
@@ -1073,7 +1073,7 @@
 # If multiple CPUs are available, do multithreading in mpeg2enc
 if $MULTIPLE_CPUS; then
     yecho "Multiple CPUs detected; mpeg2enc will use multithreading."
-    MTHREAD="--multi-thread 2"
+    MTHREAD="--multi-thread 3"
@@ -1125,9 +1125,9 @@
     # Override the above A_ and V_ variables by 'eval'ing the output of
     # 'idvid -terse' on the infile. Exit on failure.
     # (Yes, I know eval==evil. Deal.)
-    if eval $(idvid -terse "$IN_FILE"); then :; else
-        runtime_error "Could not identify source video: $IN_FILE"
-    fi
+    #if eval $(/usr/local/bin/idvid -terse "$IN_FILE"); then :; else
+    #    runtime_error "Could not identify source video: $IN_FILE"
+    #fi
     # Check for available space and prompt if it's not enough
     # not needed if using ffmpeg to encode video and audio "at once"
@@ -1811,7 +1811,7 @@
     yecho "Using ffmpeg to encode audio and video."
-    FF_BITRATE="-b ${VID_BITRATE}k -ab ${AUD_BITRATE}k -ac 2"
+    FF_BITRATE="-b ${VID_BITRATE}k -ab ${AUD_BITRATE}k -ac 6"
@@ -1891,7 +1891,7 @@
         #AUDIO_CMD="$PRIORITY mplayer $MPLAYER_OPTS -quiet -vc null -vo null $MP_AUDIOTRACK_CMD -ao pcm:waveheader:file=\"$AUDIO_WAV\" \"$IN_FILE\""
-        AUDIO_CMD=( $PRIORITY ffmpeg $CLIP_SEEK $FF_LENGTH -i "$IN_FILE" $ASYNC1 $AUDIO_MAP -ar $SAMPRATE -ac 2 -acodec pcm_s16le -y "${AUDIO_WAV[@]}" )
+        AUDIO_CMD=( $PRIORITY ffmpeg $CLIP_SEEK $FF_LENGTH -i "$IN_FILE" $ASYNC1 $AUDIO_MAP -ar $SAMPRATE -ac 6 -acodec pcm_s16le -y "${AUDIO_WAV[@]}" )
         # Generate or dump audio
         yecho "Normalizing the audio stream${s}."
@@ -1925,7 +1925,7 @@
         AUDIO_ENC=( "${AUDIO_ENC[@]}" -i "${AUDIO_IN_FILE[@]}" )
         yecho "Encoding audio stream to $AUD_SUF with the following command:"
-    AUDIO_ENC=( "${AUDIO_ENC[@]}" -vn -ab ${AUD_BITRATE}k -ar $SAMPRATE -ac 2 )
+    AUDIO_ENC=( "${AUDIO_ENC[@]}" -vn -ab ${AUD_BITRATE}k -ar $SAMPRATE -ac 6 )
     AUDIO_ENC=( "${AUDIO_ENC[@]}" -acodec $AUD_SUF)
     $DO_NORM && AUDIO_ENC=( "${AUDIO_ENC[@]}" "${AUDIO_WAV_MAP[@]}" )
@@ -2079,6 +2079,16 @@
     runtime_error "There was a problem multiplexing the audio and video together."
+# Subtitles: if .idx and .sub files with same basename of the input file exist,
+# mux them in the output file.
+if [[ ( -e $IN_FILE_BASE.sub ) && ( -e $IN_FILE_BASE.idx ) ]]
+	spumux -s0 $TMP_DIR/$OUTNAME-sub.xml <$OUT_FILENAME >$TMP_DIR/$OUTNAME.sub.mpg
 $FAKE || write_stats

Alessio Sangalli (

Also on Fandom

Random Wiki