Saturday 11 April 2020

Using HandBrake to encode video DVDs

Now that I have a lot of spare time, I decided to re-encode some of the video DVDs I ripped years ago. I have tried various programs on Linux, such as dvd::rip, dvdbackup and HandBrake. I found some results poor, I could see TV scan lines in the result, or motion blur. This time on the recommendation of some reviews I decided to try HandBrake.

This turned out to be an excellent choice because HandBrake has come far over the years. It encodes to MP4 a.k.a M4V. My older encodes were a mix of AVI and MP4. HandBrake is very thorough. Even though I chose the Very Fast 720p30 profile the quality was great. (I didn't want to spend a lot of CPU time on higher quality as the source doesn't have enough quality anyway.) I also liked that there is a CLI version called HandBrakeCLI which I ran in scripts to extract separate chapters from titles.

Assuming you have a multi-core CPU, you may wish to use the taskset command to limit the number of cores used. When I set no limit on HandBrake, it used all the cores and I could see in the system log that the CPUs got throttled when they got too warm. There was no noticeable effect on interactive response, I could still surf the Internet and do other things. Another effect was fast encoding caused a read rate from the DVD drive so high that an external one on USB would occasionally reset and break the encoding. If scripted, I can just run it on the side and come back when it's finished. Typically my jobs ran at about 3x real time. So a 2 hour movie would be done in about 40 minutes.

Speaking of reading from the drive, it's best if you can copy the DVD to an ISO image on disk first to reduce wear. And if there are bad blocks in the DVD you might want to use ddrescue to recover as much as possible first. A tip, even though the DVD might have CSS, you want to do an image copy so that HandBrake can do the normal CSS decrypting.

Do try to find a ready made package for HandBrake. At first HandBrakeCLI didn't work for me, the loader said that it couldn't find symbols from the libdvdcss library. I decided to build from source. This took a couple of hours even on my multi-core CPU. And the problem didn't go away. Then I noticed that I had very old versions of HandBrakeCLI in my /usr/local/bin directory. There was absolutely nothing wrong with the latest package. I had been running a much older version. Duh!

No comments:

Post a Comment