House of Gnomes: it’s a house, full of gnomes, who write stuff.

Choose a Topic:

Jun '12

Creating a DVD music mix disc from mp3’s

When I bought my car, I specifically asked if the in dash cd player supported mp3 cds. I was assured at the time by the salesman that it did in fact play mp3 cds. Alas, this turned out to not be true, and I’ve been limited to only playing audio cds in my car. My car has a rear entertainment center with a DVD player, and I’ve been toying with the idea for a while on making a music mix DVD.

Here’s how I did it.

  1. I put together my list of mp3s that I wanted to include in this disk. I wanted to make use of the id3 tags, so I made sure that all of them had valid Song Name, Artist and Album fields
  2. I installed the necessary tools for this project. I’m including the versions I have because I know syntax changes on a semi-regular basis for some projects.
    • id3v2-0.1.12-13.1
    • ImageMagick-
    • ffmpeg-0.10.3-1.1
    • dvdauthor07-0.7.0+-2.1
  3. First part of the process is to convert the id3 tags to version 2, so I know the format of the metadata. I’m going to use U2 – With or Without You as my specific example here
    id3v2 --convert "U2 - With Or Without You.mp3"
  4. Next, parse out the title, artist and album from the id3 metadata.

    title=`id3v2 -l "U2 - With Or Without You.mp3" | awk '/^TALB/ {
    album = $0
    sub(/.*): /,"", album)
    /^TIT2/ {
    title = $0
    sub(/.*): /,"", title)
    /^TPE1/ {
    artist = $0
    sub(/.*): /,"", artist)
    END {print title "\n" artist "\n" album}'`

    The output from the above awk statement should appear as follows:
    With or Without You
    The Joshua Tree
  5. I also want to pull out an updated filename for the output mpg

    outputfile=`id3v2 -l "U2 - With Or Without You.mp3" | awk '
    /^TIT2/ {
    title = $0
    sub(/.*): /,"", title)
    gsub(/ /,"_", title)
    /^TPE1/ {
    artist = $0
    sub(/.*): /,"", artist)
    gsub(/ /,"_", artist)
    END {print artist "-" title}'`

  6. Now I wanted to generate an image containing the above title information.
    convert -size 720x480 xc:black -fill white -font helvetica -pointsize 40 -draw "gravity Center text 0,0 '$title'" /tmp/$RANDOM.gif
  7. Last, I combined the mp3 with the generated image to create an mpeg2 output file.
    ffmpeg -loglevel debug -loop 1 -r ntsc -i "$background" -acodec mp3 -i "U2 - With Or Without You.mp3" -threads 4 -target ntsc-dvd -aspect 16:9 -shortest -q:v 5 -y "$outputfile.mpg"
  8. The final script can be found here
  9. Once I generated mpeg files for all my music, I restricted it down to just under 4.3 gigs so it would fit on a dvd
  10. I then generated a dvdauthor xml file to create the dvd iso. The example script can be found here. It takes in the path to the mpg files and generates a randomized list
  11. I used dvdauthor to create the VIDEO_TS directory structure and then burned the results to a dvd.
    dvdauthor -x dvddisc.xml

Comments Off on Creating a DVD music mix disc from mp3’s