7.11. Making a high quality MPEG4 ("DivX") rip of a DVD movie

Ripping a DVD title into a maximally high quality MPEG4 (DivX) file involves many considerations. Below is an example of the process when there is no file size goal (other than perhaps fitting the result into 2GB). libavcodec will be used for the video, and the audio will be copied as is without any changes.

7.11.1. Cropping

Play the DVD and run the crop detection filter (-vf cropdetect) on it. This gives you a crop rectangle to use for encoding. The reason for cropping is that many movies are not shot in a standard DVD aspect ratio (16/9 or 4/3), or, for whatever reason, the picture does not properly fill the frame. So you want to crop out the pointless black bars when you rip. It also improves the quality of the rip since the sharp edge of the black bars wastes a lot of bits. A common aspect is 2.35, which is cinescope. Most big blockbuster movies have this aspect ratio.

7.11.2. Quality level

Next you need to choose the desired quality level. When there is no need to fit the resulting file on CDs or the like, using constant quantizing AKA constant quality is a good choice. That way each frame is given as much bits as its needs to keep the quality at the desired level, but multiple encoding passes are not needed. With libavcodec, you get constant quality by using -lavcopts vqscale=N. vqscale=3 should give you a file below 2GB in size, depending mainly on the movie length and video noisiness (the more noise, the harder it is to compress).

7.11.3. Files over 2GB

If the file resulting from constant quality encoding is over 2GB big, you will have to create an index to be able to view it properly. Either

  • play the file with -forceidx to create an index on the fly or

  • use -saveidx to write an index to a file once and -loadidx to use it when playing the file.

If this bothers you, you may want to keep the file size below 2GB.

There are three ways to avoid this. You can try encoding again using vqscale=4 and see if both the resulting file size and picture quality are acceptable. You can also use 2 pass encoding. As you will be copying the audio track as is and hence know its bitrate, and you know the running time of the movie, you can compute the required video bitrate to give to the -lavcopts vbitrate=bitrate option without using 3 pass encoding.

The third and possibly the best option may be to slightly scale down the resolution. The uniform slight softening and loss of detail is visually more appealing than the blockiness and other artifacts caused by MPEG compression. Scaling down also effectively reduces the noise of the picture, which is good, as noise is hard to compress.

7.11.4. Deinterlacing

If the movie is interlaced, you may want to deinterlace it as part of the ripping. It is debatable whether deinterlacing should be done at this stage. The benefit is that deinterlacing when converting to MPEG4 makes compression better, and viewing easier and less CPU intensive on computer monitors as no deinterlacing is required at that stage.

If deinterlacing at the ripping stage is a good idea depends on the DVD. If the DVD is made from film, which was shot at 24 fps, you can as well deinterlace while ripping. If, however, the original was 50/60 fps video, converting into deinterlaced 23.976/25 fps video will lose information. If you do decide to deinterlace, you can further experiment with different deinterlacing filters. See http://www.wieser-web.de/MPlayer/ for examples. A good starting point is -vf pp=fd.

If you are both cropping and deinterlacing, deinterlace before cropping. Actually, this is not necessary if the crop offset is vertically a multiple of 2 pixels. However with some other filters, like dering, you should always crop last, so it's a good habit to put the crop filter last.

7.11.5. Inverse telecine

If you are ripping a PAL DVD, which is 25 fps, you do not need to think about the fps. Just use 25 fps. NTSC DVDs on the other hand are 29.97 fps (often rounded to 30 fps, but that is not what they are). If the movie was shot for TV, you again do not need to touch the fps. But if the movie was shot on film, and hence at (exactly) 24 fps, it has been converted to 29.97 fps when making the DVD. That conversion where 12 fields are added to each 24 frames of film is called telecine. For more info about telecine, see a Google search for "telecine field 23.976".

In case you have such a telecined DVD, you will want to do inverse telecine, that is convert the movie to 23.976 fps (29.97*4/5). Otherwise camera panning will look jerky and awful. You can use -ofps 23.976 for this. Anything that is shown in theatres is shot on film and needs inverse telecine, TV shows do not.

7.11.6. Scaling and aspect ratio

For best quality, do not scale the movie while ripping. Scaling down obviously loses detail, and scaling up causes artifacts and obviously makes the file larger. Pixels in DVD movies are not square, so DVD movies include info about the correct aspect ratio. It is possible to store the aspect ratio in the MPEG4 header of the output file. Most video players ignore this info, but MPlayer honors it. So if you are only going to use MPlayer for viewing the ripped file, you do not need to scale the movie, just pass -lavcopts autoaspect to MEncoder and things will automagically work right. If you must scale the movie, be careful about getting the size right especially if you do cropping.

7.11.7. Summing it up

With all of the above mentioned in mind, a suitable encoding command might be

mencoder dvd://1 -aid 128 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:trell:autoaspect \
  -ofps 23.976 -vf crop=720:364:0:56 -o Harry_Potter_2.avi
Here dvd://1 gives the DVD title to rip. Option -aid 128 says to use audio track 128, and -oac copy to copy it as is. You'll have to use MPlayer to find out the right values for these options.

Options vhq:v4mv:trell for -lavcopts improve quality versus bitrate, but make encoding take longer. Especially trell slows encoding down but also increases quality visibly. If you want to deinterlace, add a pp filter to -vf, for example -vf pp=fd,crop=720:364:0:56 (in that order). If you don't need inverse telecine, leave out the -ofps 23.976.

Наш баннер
Вы можете установить наш баннер на своем сайте или блоге, скопировав этот код:
RSS новости