## Burn CD’s and DVD’s from emacs using dired and dvd+rw-tools

I recently explored burning discs from the command line. To make things even more convenient, I can employ emacs dired to help in selecting the files. That is, suppose I have some files in a directory opened in dired. I can mark the files I want to be burnt, and invoke ! (dired-do-shell-command) on those files with the command:

 <pre class="src src-sh">growisofs -dvd-compat -input-charset=ISO-8859-1 -full-iso9660-filenames -Z /dev/sr0 -R -J -pad * &amp;&amp; eject /dev/sr0


I can also invoke & (dired-do-async-shell-command) with the above command without the && eject /dev/sr0 (the * arguments will also be passed to this) to continue using the current emacs instance and view the progress in stdout.

## Rip dvd’s (iso’s) to high quality avi

I recently needed to rip some videos from dvd’s so I can have them on my computer in smaller files. I prefer the command line, so I use MEncoder that comes with mplayer. Supposedly AcidRip is a good interface that automates things for MEncoder. I wrote some scripts based on my research into how to do rip dvd’s from the command line. Note that I have -dvd-device /path/to/iso in all of the scripts since I’m doing videos from an iso file. If you are doing it from disc, remove this portion of the commands.

dvdiso2xvid.sh (one pass, based on xvid):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>


## Usage: dvdiso2xvid.sh file.iso ## http://www.howforge.com/how-to-encode-dvd-to-avi-using-mencoder ## http://forum.videohelp.com/threads/288190-(SOLVED)-Need-mencoder-help-certain-files-have-no-audio for file in “$@” do bn=basename "$file" NameNoExt=${bn%.*} ## no extension mencoder dvd://1 -dvd-device “$bn” -oac mp3lame -lameopts mode=2:cbr:br=128:vol=0 -ovc xvid -xvidencopts bitrate=-1 -vf scale -zoom -xy 480 -o “$NameNoExt.avi” done dvdiso2lavc.sh (one pass, based on libavcodec): <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>  ## Usage: dvdiso2lavc.sh file.iso ## http://www.howforge.com/how-to-encode-dvd-to-avi-using-mencoder ## http://forum.videohelp.com/threads/288190-(SOLVED)-Need-mencoder-help-certain-files-have-no-audio for file in “$@” do bn=basename "$file" NameNoExt=${bn%.*} ## no extension mencoder dvd://1 -dvd-device “$bn” -oac mp3lame -lameopts mode=2:cbr:br=128:vol=0 -ovc lavc -lavcopts vcodec=mpeg4:vhq:v4mv:vqmin=2 -o “$NameNoExt.avi” done

dvdiso2xvid_2pass.sh (two passes (so better quality), crop images (for use with widescreen), based on xvid):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>


VBR=1000 ## higher, better quality ABR=128 ## 96 recommended for file in “$@” do rm -f divx2pass.log bn=basename "$file" NameNoExt=${bn%.*} ## no extension # start a timer to kill mplayer (sleep 5 && killall mplayer)& # start the mplayer cropdetect on DVD’s chapter 4 mplayer dvd://1 -dvd-device “$bn” -chapter 3 -vf cropdetect &> mplayer.tmp # get last crop value from mplayer output and store in variable CROP_VALUES=$(awk -F‘crop=’ ‘/[CROP]/{f=$2} END{print f}’ ./mplayer.tmp |cut -d‘)’ -f1) # print detected crop values echo -e “nnDetected crop values = ${CROP_VALUES}nn” mencoder dvd://1 -dvd-device “$bn” -vf crop=${CROP_VALUES} -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=${VBR}:pass=1 -oac copy -o /dev/null mencoder dvd://1 -dvd-device “$bn” -vf crop=${CROP_VALUES} -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=${VBR}:pass=2 -alang en -oac mp3lame -lameopts br=${ABR}:cbr:vol=0 -o “\${NameNoExt}.avi” done

Basically, if you want better quality, then increase the video bitrate. However, this means the final output file will be bigger. Double passing also makes better quality output because the second pass uses information from the first pass to increase the bitrate at the part of the video that is needed. Good references are here and here. For me, I think setting the video bitrate to 1000 produces a pretty good quality video for the size. If you have a constraint on the file size (such as 690mb to fit on a CD), you can find a calculator here and here. simplerip is pretty cool in that it will create all the commands you need after you input your requirements (such as crop, file size, scale, volume, etc). However, I think my dvdiso2xvid_2pass.sh is a pretty decent script that automates everything and gives good quality output.

## Create a video slideshow from images automatically

On a Mac, creating a video slideshow with some pictures is easy with iPhoto and iMovie. I haven’t found similar programs on the Linux side (yet). I mean, there are many photo manager apps such as F-Spot and Shotwell that can create a quick slideshow from the selected pictures, but they don’t export the slideshow into a video format that can be played anywhere (platform-indepedent). Also, they don’t have nice transitions between pictures. digiKam supposedly supports these features, but I think they’ve been taken out.

I found dvd-slideshow that lets me create a video slideshow with transitions from the command line. On ubuntu, install by

 <pre class="src src-sh">sudo apt-get install dvd-slideshow


Suppose I copy all the pictures I want in a directory. Run the following commands to create a vob (dvd) file:

 <pre class="src src-sh">dir2slideshow -t 5 -c 1 -n <span style="color: #ffa07a;">"Title"</span> -r /path/to/pics/ <span style="color: #ff4500;">## </span><span style="color: #ff4500;">title should be ascii only ## generate some files (txt file contains instructions)</span>


dvd-slideshow -n Name.Of.VOB.file -a /path/to/mp3/song Title.txt ## select name of out file, add audio to be played, and point to txt file with instructions ## for multiple audio files, add multiple -a /path/to/song; songs do not repeat, so add multiple -a if you want songs to repeat

## let’s convert to avi: mencoder out.vob -ofps 30 -ovc xvid -oac mp3lame -lameopts abr:br=128 -srate 48000 -vf scale -zoom -xy 720 -xvidencopts fixed_quant=4 -o out.avi

### UPDATE 12/24/2010: dvd-slideshow-editor

My example above is very basic. You can actually modify the generated text file to modify the way the picture is presented (cropping and ken burn effects). You can also create a dvd-menu for your dvd. See this post for one person’s overview. See the wiki for a more complete overview.

Note that there are many GUI frontends to dvd-slideshow, the simplest of which is probably dvd-slideshow-editor. To install on Ubuntu,

sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n