PAL to NTSC

October 25th, 2009, 1:15 pm

I was asked to convert some European (PAL) dvds to the American (NTSC) format. With the help of a few linux tools, the process is pretty painless. A cautionary note: the process takes about 3 hours for one dvd using  my AMD X2 7750.

What you need:

First, we need to rip the DVD to the computer. We can do this by using dvdrip or vobcopy. Vobcoby is a simple command line utility that rips vob files straight from the dvd to the hard drive. dvdrip is a gui tool which is very easy to use. Load it up, create a new project, select the rip tab, and pick the title you want to rip. Ripping the dvd will probably take anywhere from 15-20 minutes.

Vobcopy Example: cd /home/pyther/dvdrip and vobcopy /dev/sr0

Next, we want demux (seperate) the audio and the video. ProjectX is very easy to use for this task and ProjectX insures the video and audio stay in sync.

To Demux the video:

This result in the following files being created:

If there are multiple audio tracks you will see zorro-001.ac3, zorro-001[1].ac3, zorro-001[2].ac3
In my case:

Lets clean up the directory right now:

There are two main differences between PAL and NTSC. First, PAL plays at 25fps whereas NTSC plays at 29.97fps. Secondly, PAL uses a resolution of 720×576, but NTSC uses a resolution of 720×480. We won’t worry about the fps right now. We will concern ourselves with resizing the PAL video to 720×480. This can be done using the filters available in avidemux. With my videos I  was simply able to crop the black borders of the video. However if there is no black borders in the video, you can crop the actual movie or you could resize the movie to something smaller than 720×480.  After resizing you can then add black borders to get the video back to 720×480. I don’t know an easy way to do this, you will just have to play with the filters until you get a resolution of 720×480.

To extract the video:

A blank dvd can hold approximately 4300MB. Therefore we need to calculate how much space our audio files take up.

In my case:

tux:zorro $ du -hs *.ac3
420M	English.ac3
420M	Hungrian.ac3

The total size of the audio is 840MB. 4300MB – 840MB = 3460MB. I would leave about a 10-20MB gap incase the file is a bit bigger than the target size. Therefore the target size you would enter would be 3440.

Now you just need to find something to do for about 2 hours. The time it takes to encode the file will greatly depend on the speed of your processor.

After the file is done encoding we need to convert it from 25fps to 29.97fps. This is done by applying a pulldown to the file. I do not quite understand this concept. For more information read this: http://neuron2.net/dgpulldown/dgpulldown.html.

Steps to convert video:

Next we need to multiplex the audio and video together.
Use mplex to do this: mplex -f 8 -o output.mpg video.m2v english.ac3 hungarian.ac3

Lastly, we need convert the mpg2 file to a dvd structure. Below is a simple config that will cause the video to play right away, with the languages defined, and chapters set.

<dvdauthor dest="./dvd">
 <vmgm></vmgm>
   <titleset>
     <titles>
       <audio lang="hu" />
       <audio lang="en" />
       <pgc>
           <vob file="/home/pyther/Patriot/Patriot.mpg"  chapters="00:00:00.000,00:10:37.760,
           00:17:18.920,00:21:38.160,00:25:02.920,00:29:05.720,00:35:16.960,00:46:57.760,
           00:49:59.560,00:53:24.360,00:55:17.680,00:59:41.880,01:03:37.160,01:04:51.480,
           01:10:23.800,01:16:28.280,01:19:36.040,01:24:29.040,01:28:44.160,01:34:06.760,
           01:46:24.560,01:53:05.120,01:54:57.720,01:59:47.000,02:15:24.520,02:22:35.840,
           02:26:53.680,02:29:46.160" />
       </pgc>
     </titles>
   </titleset>
</dvdauthor>

Save the file as dvd.xml in your working directory. Of course you will want to change the chapters and languages accordingly.

To get the chapter times from the source dvd you can run the following:

dvdxchap /dev/sr0 > chapters.txt
cat chapters.txt | cut -d'=' -f2 | sed -n 'p;N' | tr '\n' ',' | sed 's/\(.*\)./\1/'

Then you want to create a dvd directory: mkdir dvd
And now to create the dvd structure: dvdauthor -x dvd.xml

Finally, burn the contents of the dvd directory to a dvd and enjoy the movie!

Tags: , , , , ,
Category: Linux | Comment

Leave a Reply