Converting a DVD to HD/SD iTunes

I buy quite a lot of TV Series box sets on DVD, because they’re cheaper than on iTunes. But I want to copy them into iTunes and get the iPod-style SD and AppleTV-style HD versions, encoded roughly the same as the iTunes store has them.

Here’s my shell script that takes the DVD and converts individual titles into HD and SD simultaenously, then writes in the right mp4 tags so that iTunes will import them as HD/SD.

Because the device, main video/audio tracks and title numbers are different on every DVD, those are the elements you can change

It requires mp4v2, ffmpeg and transcode from macports

if [ "$1x" == "x" ]; then echo "$0 dev video audio titlenum cnid aspect movie|tvshow filename ($0 /dev/disk1 0:0 0:1 2 289233333 16:9 tvshow s01e01)"; exit; fi
if [ "$6" == "16:9" ]; then isz=1280x720; fi
if [ "$6" == "4:3" ]; then isz=1024x768; fi
tccat -i $1 -T $4,-1 | ffmpeg -i - -f mp4 -vcodec libx264 -vpre hq -vpre libx264-ipod640 -threads 0 -aspect $6 -s $isz -vb 4096000 -ac 6 -ab 448000 -map $2 -map $3 $8\ \(HD\).m4v -s 640x480 -vb 1572000 -ac 2 -ab 192000 -map $2 -map $3 $8.m4v
mp4tags -i $7 -s $8 -H 1 -I $5 $8\ \(HD\).m4v
mp4tags -i $7 -s $8 -H 0 -I $5 $8.m4v

Comments

    Leave a comment