Author Topic: Getting audio off my DVDs.  (Read 19368 times)

0 Members and 1 Guest are viewing this topic.

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« on: January 27, 2007, 08:51:54 pm »
So... I got my PC fixed up, and treated myself to an external DVD writer. Should be useful for archiving, plus I can watch DVDs on it. Except of course that my PC is a linux system, and DVD playback isn't always straightforward on one of those. With a bit of snagging packages from unofficial SuSE sites, a bit of googling and a bit of compiling from source, I managed to get things to the point where Kaffeine could play Region 2 DVDs. Good, pats on the back for me.
But then, of course, I had to look at my concert DVDs, and think "wouldn't it be nifty if I could get the audio from that and convert it to MP3 or Ogg or something that I could play along with my regular music collection?" And that turned out to be an even bigger can of worms. I was again thrown into Dependency Hell, with just about any of the most-used tools refusing to run or compile on my system, despite me being sure, at least in some cases, that the libraries they needed were in fact present on my system. But if you get one package from Packman, one from the official SuSE discs, and another from source code, things get a bit messy.
Another problem was that programs that did run, such as Mencode, come with some seriously involved command line options (and one program that might serve as a front end came with some nasty disclaimers about its code quality and introduced two fresh dependencies). Mencode requires about five command line options just to extract a single file, and the documentation is less than helpful. It wouldn't be a problem if among the examples there'd be at least some based on someone wanting to extract just the audio. As it is, I have no idea how to do that.

In short, is there an easy way to 1) extract audio from DVDs without also filling my hard drive with video files; 2) on a SuSE linux system; 3) without going nuts from learning hundreds of cryptic command line options, and 4) without spending days in Dependency Hell?

I am aware that if you want to work with multimedia on linux, a good way to start is not to do it on a SuSE system, but it's the one I've got installed, it's the one that I understand slightly better than other distributions, and while I'm willing to put in some effort for this (and have, oh, boy, I have), switching just for this is more trouble than it's worth.

But you Xepherites have been so helpful with my PC troubles (thanks again for that!), maybe you know the answer to this one as well!
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #1 on: January 28, 2007, 11:08:53 am »
It's not actually DVD Audio, is it? It's a normal DVD that you want audio-only extracted from, yes? If that's the case, the answer is mplayer. Simply adding the command line option "-ao pcm" (sets "audio output" to "PCM" file/dump) to mplayer will cause it to dump the audio stream to a regular wave file (by default called "audiodump.wav") From there, you can use whatever program you want to compress/covert it. To quickly dump audio, the thing you want is...
Code: [Select]
mplayer -vc null -vo null -ao pcm dvd://1Where "1" is the title number you wish to play/dump. On most movie DVDs, title #1 is the main movie (and other titles are usually bonus features, or previews and such.) A simple "mplayer dvd://1" will actually play the title, so you can see if it's the right one before dumping it. The two other options set the video codec and video output to null... basically, tells it to skip the video entirely so it dumps the audio faster. I know you said you didn't want a lot of esoteric options, so you can actually skip those, it'll just go slower.

If you want mp3, "lame audiodump.wav songtitle.mp3" (make "songtitle" whatever you want) then run mplayer for the next title and repeat. If you want Ogg... "oggenc -o songtitle.ogg audiodump.wav" I find the default options for both oggenc and lame to result in quite satisfactory quality, so I don't do a lot of tweaking.

Of course, all this depends on having the right packages installed. I don't know which packages would be required on SuSE, but at least mplayer, lame, and (optionally) ogg would be needed. Mplayer needs dvd support included, don't know if SuSE does packages without that, but some distros do.

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #2 on: January 28, 2007, 11:41:15 am »
I think Lame may actually be missing on my system (at least, when I tried to use mencoder, it reported Lame as being missing, but that doesn't mean it's not actually there), but that at least is easy to fix (SuSE tends to play the legal aspects very safe, so even an interpreted source library like lame is treated as patent-breaking executable code).

Mplayer, on my system, is a curate's egg. It kind of, sort of works, but DVD playback with sound is still broken. That is, when I use it with the GUI and for playback through the audio drivers. But Mencoder, which is part of the Mplayer codebase, knows where to find the sound, so until I discover that this is a problem, I'm going to pretend it's not:)

Two comments for the benefit of anyone stumbling upon this thread in six months time: I will need some more options for this. Specifically, I'll need to set the -dvd-device /dev/sr0 , because otherwise it'll look for /dev/dvd. And I will probably want to be able to set a higher bitrate than the default, because I'm a bit anal about that. I'll figure that out myself though.

I have one mixed-session DVD Audio disc that I may want to try to extract or indeed play. Since buying it, I haven't found a single DVD player that could find the Audio content; they all default to showing the 10 minutes of video and don't offer any options to switch to audio ("pure" DVD Audio disks at least run on my cheapo DVD player). But that's not urgent, because I have the same audio content on CD anyway.

Hmmmm... I think on most concert DVDs, individual tracks are "scenes" within the main movie. Is there a way to separate them out on that mplayer command line? Even then, getting an entire DVD ripped will require some work, but I think I can figure out how to write a batch script for that myself.

*thinks that in addition to getting some of his favourite music out there, he's also building up some marketable skills with this*

Thanks!
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #3 on: January 28, 2007, 08:48:48 pm »
Right. Figured these things out. To encode a chapter from a DVD, I have to add "-chapter x-x" with x being the chapter number to the mplayer command line Xepher suggested. You have to add it twice because otherwise Mplayer will encode from the start of the chapter to the end of the DVD.  Also, you may need to figure out which track on the tracklist is which chapter on the DVD by trial and error
Currently I manually rename each audiodump, move it to a directory that serves as a sandbox, and use
Code: [Select]
for s in *.wav;do oggenc --resample 44100 --quality 6 $s;donethe basic syntax of which I snagged from a webpage with similar instructions for PNGout.. Those instructions needed some tweaking before they worked with the PNGout installation on my machine, by the way.
I'd like to be able to use a similar loop for mplayer... If I can read out the list of chapters on a DVD (something like 'for s in /dev/sr0/*.vob" except that the number of *.vob files doesn't correspond to the number of chapters, and I can only access them as /media/DVDtitle anyway)
and tell MPlayer to output filenames based on a variable, then the hassle of ripping songs will be dramatically reduced. This is the sort of thing GUI front ends do well, but so far all the front ends I've tried either refused to download, refused to build or crashed the moment the DVD was accessed.
So, how do I tell it to separate out the chapters? Once that's dealt with, I'm good.
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #4 on: January 28, 2007, 08:49:36 pm »
Quality is easy... "lame -V 2 audiodump.wav output.mp3" -V sets the quality for VBR (2 is better quality than 4) , and VBR gets better quality than setting an actual (constant) bitrate does.

As for mplayer not getting audio out through your sound system, it shouldn't matter for dumping audio, as it's most likely the sound output system isn't configured right. If you wanna try it, try "-ao alsa" or "-ao arts" to try the KDE sound mixer applet thing.

I see you already figured out dvd device... /dev/dvd symlinks to whatever the actual device is on most systems. There is an mplayer config file that you can set some of the stuff in, so you don't have to type it on the command line all the time. ~/.mplayer/config

Scenes... Scenes are just a chapter number to jump to. Chapters are basically the skip-to points you find on DVD movies. Some "scenes" are actually multiple chapters though, so keep that in mind. "mplayer dvd://1 -chapters 3-9" would play title one, chapters three to nine. lsdvd is a nifty little tool that will basically list titles, chapters, angles, languages, etc. on a dvd. Or, lacking that, run mplayer on the dvd with the "-v" (verbose) option for a few seconds, then quit. If you look at the output in the terminal, it'll show you extra info about the dvd.

As for the DVD audio... I've never messed with that, so I have no idea. I do know that if you can make mplayer play it, then it can dump it to a wave file though. :-)

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #5 on: January 28, 2007, 09:28:11 pm »
Hee, we posted within a minute of one another. So you posted just as I had a whole batch of new questions :)
I don't think /dev/dvd symlinks to my external driver... it returns errors when I use it. Probly just a matter of how SuSE handles USB drives; it doesn't know what /dev/sr0 is supposed to be until that device actually reports that something has been loaded in it. But I'll add the config option next time I'm on the home machine (I went back to my studio almost immediately after posting my previous message).

Yeah. I figured out the -chapters option myself; now all I need to do is figure out how to make good use of them. lsdvd should handle, but sourceforge refused to let me have it earlier this evening.

I'm learning a lot of stuff here, but it's like putting together a jigsaw puzzle. What I want should be possible, but I haven't got all the pieces I need.

Mplayer's man pages are as unwieldy as the application itself; the man page format isn't up to presenting that much info. Bleagh.
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #6 on: January 29, 2007, 01:22:05 am »
Okay, first let me explain something about (video) DVDs... they have a filesystem, so they CAN be read like regular data discs. If you mount one and see the files, you basically get a video_ts folder, and inside that, a bunch of files, the main ones are *.vob. These do NOT neccessarily correspond to particular chapters in a DVD. In fact, on most discs, you'll notice that they're all the same size, usually 1gig. They're split up this way because a lot of older file systems and operating systems (like windows 95-98) had trouble with files over one gig in size. They all just get concateated together (end-to-end) during actual play back. Seeking (such as for chapters) is handled internally in the files, so chapter breaks can occur anywhere in a file, and a chapter can span between two files. Generally speaking, you should never need to access the .vob files directly.

This brings us back to mplayers -dvd-device command. This tells mplayer what the physical device(file) for the DRIVE is. In your case, /dev/sr0 That "file" is actually your DVD drive itself. Mplayer sends commands to that, and reads raw data back. It doesn't in anyway care where/what .vob files or such are on the disc. However, your GUI seems to be automounting the dvd as a data disc under /media/dvdTITLE/ You shouldn't need to mess with any of that in there, and your idea of "for s in /dev/sr0/*.vob" won't work. First off, the /dev/sr0 is the actual drive's I/O control, NOT a directory with the disc's files in it. Secondly, as I mentioned, .vob files don't necessarily correspond to actual chapters. (I've seen one disc that did, but I wouldn't count on it)

LSDVD moved recently, try this direct download http://superb-west.dl.sourceforge.net/sourceforge/lsdvd/lsdvd-0.16.tar.gz

In your oggenc settings, is there a reason you resample? You said you were picky about quality, yet you're dropping the sample rate.

Here's a short bash script (dvd2ogg.sh) I tweaked that might work for you. Set the title/quality variables at the beginning. Specify options as space separated chapter ranges.
Ex: ./dvd2ogg.sh 1-3 4-4 5-9 10-11 12-12
Code: [Select]
#!/bin/bash


quality=6
title=1

n=1
number=$#

echo ""
echo "$number tracks to rip"

until [ -z "$1" ]  # Until all parameters used up...

do

chapters="$1"

echo "Reencoding $file to ogg: quality $quality"
mplayer -dvd-device /dev/sr0 -vc null -vo null -ao pcm dvd://$title -chapters "$chapters"
oggenc --quality $quality -o "${chapters}.ogg" "audiodump.wav"

shift
let n+=1

done
rm audiodump.wav
Code is a tweaked version of another script I wrote, but I haven't tested this exact thing yet. Lemme know.

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #7 on: January 29, 2007, 01:27:30 am »
Oh, another option you might want to consider... just dump/encode the entire title (all chapters) then go in with a tool like oggsplt (part of the mp3split package I believe) or a gui sound editor and split up the tracks there. That way you can listen to what you're doing, and don't have to muck about with dvd layouts so much. If you use a gui editor, I'd suggest splitting the audiodump.wav file before encoding to ogg or whatever.

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #8 on: January 29, 2007, 08:11:50 am »
LSDVD refuses to build with a libdvdread-related error in make:
Quote
checking for dvdread/ifo_read.h... no
configure: error: Header files for dvdread not found
This is a bit of a bummer, because the first DVD I tried your script on had an insane title/chapter structure that left me with no option but to guess what was where. Right now, it seems that all the chapters of the first concert are in movie title 3, except the first song/chapter, which I haven't found yet. There's another concert on the disk that I hope is on title 4, but as there are 7 titles I might be looking for it for a while.
Thanks for the script, though. I'll try it again on another disk soon.
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #9 on: January 29, 2007, 04:43:37 pm »
Quote from: Xepher
In your oggenc settings, is there a reason you resample? You said you were picky about quality, yet you're dropping the sample rate.
I forgot to answer this one. No reason, other than I was playing around with the settings, vaguely remembered something about resampling in some manual, and set that option. I can think of a reason to resample, but that would apply at an earlier stage, when ripping the files to WAV, if I ever want to put those WAVs on CD. In my own latest attempts, I've dropped the resample option.
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #10 on: January 30, 2007, 01:27:32 am »
Yeah, you need libdvdread to build lsdvd I guess. Did you try "mplayer -v dvd://1" yet?

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #11 on: January 30, 2007, 06:45:13 pm »
I have, yeah. Can't quite recall what it output at the time, though. I was focusing more on the dvd2ogg script.
Your original version didn't quite do the trick - it still output a single large file. No worries, this was an opportunity for me to study bash scripting a bit. I ripped out your [until] construct and replaced it with a [for] loop, with its loop-ending number hardcoded into the script for now, so I have to edit the script for each new DVD. I'll polish it up eventually. The incrementig variable provides the chapter number and the title string for the oggs. Right now, it's not clever, but as long as I know which title the songs are on, I can work with it.

The problem, though, is that knowing where to find the songs so far involves quite a bit of guesswork. Playing the concert helps, but is time-consuming, and shouldn't be necessary in any case. But one DVD I've looked at had 36 titles with up to 9 chapters each. So I do want to run lsdvd. But I can install libdvdread until I'm blue in the face, it still returns
Quote
checking for dvdread/ifo_read.h... no
configure2: error: Header files for dvdread not found
I know where that header file is. I have a vague idea that I can either offer a command line option to tell ./configure where it is, or tweak ./configure itself to tell it where to find it. But the configure script for lsdvd is a huge unwieldy beast, and the help is a bit terse. Using ---includedir= doesn't seem to help. Am I even on the right track with this?
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #12 on: January 31, 2007, 03:59:58 am »
Yeah, there should be a way to force it to find the header file. I'm really not that great at the compiling stuff myself. I think most configure scripts can do ./configure --help and it will show you what options it supports. I don't really know anything more specific. I assume SuSE doesn't have a package for lsdvd?

reinder

  • Full Member
  • ***
  • Posts: 142
    • View Profile
    • Rogues of Clwyd-Rhan
Getting audio off my DVDs.
« Reply #13 on: February 12, 2007, 10:18:03 pm »
Well I haven't been able to make lsdvd work. I have had some success dealing with a little problem that was causing the ripping process to output white noise on some DVDs (but strangely, never on all tracks of a DVD. I think DVD authors are a bit sloppy...).
The problem was that MPlayer sometimes picked the DTS audio channel to rip, depending, I presume, on what the DVD defaults to. The 4500-line MPlayer help wasn't exactly useful in explaining to me how to make it pick another channel (I'm sure that the information is there, but not in a form that I could find or parse correctly). This tips and tricks file told me the correct option to pick ( -aid [number]), and by trial and error I found that the number that should go in there is in MPlayer's output.
Quote
audio stream: 0 format: ac3 (5.1) language: en aid: 128.
audio stream: 1 format: ac3 (stereo) language: en aid: 129.
audio stream: 2 format: dts (5.1/6.1) language: en aid: 138.
The last number in the line is what you need; in this case, 129.

So that goes into the revised script as a variable as well. To do it properly, I would have the script take input from the user, and use the default if the user didn't specify a channel. But I'm too lazy to do that...

Another little problem is that something, presumably a hardware driver or some intermediate layer, crashes if MPlayer is invoked too often. Seems like only a session restart will solve it, which is a drag. I expect that that's just some quirk of my configuration though, so no worries about trying to solve that! I don't have to have everything today, after all.
Reinder Dijkhuis
Rogues of Clwyd-Rhan | Waffle

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,328
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
Getting audio off my DVDs.
« Reply #14 on: February 13, 2007, 01:55:38 am »
Yeah, I didn't think about the multi-track audio (AID) bit with dvds, or I would've been able to tell you that option. As for the crashing... if a session restart fixes it, it's likely that it's conflicting with ARTS (the KDE sound daemon) or something similar for getting a lock on the audio device. That is, assuming you're NOT using the "-ao pcm" option when it happens. If you are, then... hmm, I don't know. I'd have to see mplayer's output to know what's wrong.