As I don’t care for the noise of an optical drive while going to sleep, have been transcoding a few favorite DVDs to USB sticks.

ffmpeg is a versatile tool, but does not support import directly from DVD media.

mplayer does however, and can stream dump.

#!/bin/bash

function dvdrip {
        mplayer dvd://${1} -chapter ${2} -dumpstream
        # adjust as needed
        ffmpeg -i stream.dump -c:a aac -b:a 128k -c:v libx264 -crf 16 -pix_fmt yuv420p -f mp4 "${3}.mp4"
        rm stream.dump -f
}

case $(lsdvd -c | md5sum | cut -b-6) in
        # [...]

        # archer 5-1
        da7c42)
                dvdrip 2   1-5 '0501 White Elephants'
                dvdrip 2  6-10 '0502 A Kiss While Dying'
                dvdrip 2 11-15 '0503 A Debt of Honor'
                dvdrip 2 16-20 '0504 House Call'
                dvdrip 2 21-25 '0505 Southbound and Down'
                dvdrip 2 26-30 '0506 Baby Shower'
                dvdrip 2 31-35 '0507 Smugglers Blues'
        ;;

        # default handler
        *)
                echo 'add config for:'
                lsdvd -c | md5sum | cut -b-6
esac

eject

With a bit of hindsight:

  • Had to re-encode a few times at the start of the process. Having a digest of the lsdvd output made this process considerably easier.
  • Not all of our smart tvs supported HEVC/h.265.
  • Same TV refused to down mix 5.1 to 2.1, thus the -ac 2 to force it.