09 May 2011

YouTube video clip to DVD in one command

You may wish to alter the device on which the DVD is burned via (/dev/sr0 in the example) or the default burn speed, or you may have a more appropriate place to store up to maybe 9GB of temporary files (the DVD content plus an ISO file of the same), however this one command turns a downloaded YouTube clip into a push-in-n-it-plays DVD:

if [ -f "$1" ]; then
    LEN=$(ffmpeg -i "$1" 2>&1 |gawk '/ Duration: / { print gensub(":[0-9][0-9]\\.[0-9][0-9],", "", "g", $2); }')
    if [ $LEN = "" ]; then
        echo No video minutes seen in the file "'$1'"
        return 1
    echo File "'$x'" does not appear to exist or is a dir or device-node
    return 1
rm -rf /tmp/DVD_temporary /tmp/DVD_temporary.iso /tmp/temporary.xml /tmp/temporary.jpg
nice ffmpeg -i "$1" -target ntsc-dvd -y /tmp/temporary.mpg
cat <<ENDOFFILE > /tmp/temporary.xml
    <vmgm />
            <vob file="/tmp/temporary.mpg" />
dvdauthor -o /tmp/DVD_temporary -x /tmp/temporary.xml
mkisofs -dvd-video -udf -o /tmp/DVD_temporary.iso /tmp/DVD_temporary
wodim -eject -v dev=/dev/sr0 /tmp/DVD_temporary.iso

It is also not too difficult to fetch YouTube downloading scripts & alter this script a little so that “nameofscript http://www.youtube.com/watch?v=ABC123DEF456” (insert real YourTube URL here) results in a clip being downloaded (in off-peak time if it suits) & burned to whatever blank DVD happens to be in the drive about 3 minutes after the download completes.

No comments: