2007-01-19 Extract MP3 and Metadata from DVD

We have quite a number of South Asian music DVDs at home. Claudia likes to scour them for dance moves, dress ideas, and the like. And I like the music. Since I like to listen to my music from MP3 players, I need to extract the DVD audio to play it. The basic stuff is simple: I assume the result is a huge MP3 file.

But the DVD has chapters more chapters than VOB files, and thus it should be possible to somehow produce one MP3 file per chapter. Any suggestions? Automatically getting the metadata from the Internet and doing all the labeling for me would be super-duper extra cool, but I’ll settle for less right now.

Comments on 2007-01-19 Extract MP3 and Metadata from DVD

Now, if I got the track and artist lists of these DVDs in electronic form, I’m sure I could write a script to put the data where it belongs. Unfortunately these are Pakistani DVDs that seem to be unknown to Google... 😄

​#Software

Comments

(Please contact me if you want to remove your comment.)

I wrote a basic script to do something like this. It doesn’t get metadata from the internet though. It is based on something I found in a comment at Lifehacker.

See http://svn.slimeslurp.net/utils/scripts/rip_audio.sh for details.

http://svn.slimeslurp.net/utils/scripts/rip_audio.sh

– ndrake 2007-01-19 13:17 UTC

ndrake

---

Awesome! Works like a charm. Thank you very much. 😄

For the curious, here’s how to figure out how many chapters there are in the first place:

~/Music/PAO Bhangra Vol. 3 $ mplayer -identify dvd://1
[...]
Playing dvd://1.
Reading disc structure, please wait...
There are 2 titles on this DVD.
There are 1 chapters in this DVD title.
There are 1 angles in this DVD title.
[...]

Suspicious! The chapters must be all on the second title:

~/Music/PAO Bhangra Vol. 3 $ mplayer -identify dvd://2
[...]
Playing dvd://2.
Reading disc structure, please wait...
There are 2 titles on this DVD.
There are 65 chapters in this DVD title.
There are 1 angles in this DVD title.
[...]

There we go! 😄

Here’s the script I’m using. Note that I don’t have artists per DVD so I removed that option. I’m also using `--preset standard` instead of `--preset medium` which isn’t mentioned in my `lame(1)` man page. And I’m deleting the wav files to save some temporary diskspace. ;)

I also think the original file linked to above has a problem with `$TITLE` vs `$title`. I had to use `dvd://$title` in my script to get it to read the chapters from the second title.

#!/bin/bash
1. This script uses mplayer and lame to rip the audio from each chapter
1. of a DVD to separate MP3 files.
1. From: http://svn.slimeslurp.net/utils/scripts/rip_audio.sh
1.
1. Thanks to hilker for the mplayer command line
1. From: http://www.lifehacker.com/software/call-for-help/call-for-help-concert-dvd-to-mp3-154044.php

1. Chapter to start with
START=1

1. Chapter to stop after
END=65

1. Title to extract from
TITLE=2

1. Album tag to use
ALBUM_TAG="Punjabi Stuff"

1. Location of mplayer binary
MPLAYER=/opt/local/bin/mplayer

1. Location of lame binary
LAME=/opt/local/bin/lame

1. For all chapters, extract the audio
for ((chapter=START; chapter <= END; chapter++))
do
    echo "Extracting audio for chapter $chapter"
    $MPLAYER -really-quiet -vc dummy -vo null \
	-af resample=44100:0:0 \
	-ao pcm:file=chapter_$chapter.wav \
	-chapter $chapter-$chapter \
	dvd://$TITLE
    echo "Converting to MP3"
    $LAME --id3v2-only --nohist \
	--preset standard \
	--tt "Chapter $chapter" \
	--tn $chapter \
	--tl "$ALBUM_TAG" \
	chapter_$chapter.wav chapter_$chapter.mp3
    # save temporary diskspace
    rm chapter_$chapter.wav
done

– Alex Schroeder 2007-01-19 22:58 UTC

Alex Schroeder