Category Archives: bend / dvd2mkv

reading, ejecting, ripping and polling dvd devices in linux; also, notes on my dvd library

It has been a looong time since I both posted in my blog and worked on my custom DVD ripper scripts.  Apparently the last time I worked on the code was last June, and even then I didn’t make many updates.

I’ve been spurred onto building up my DVD library again by a couple of things. First, I realized that my Blu-ray player has  support for Matroska videos with VobSub and SRT subtitle support!  I was not expecting that.  In fact, it’s way better than what my PS3 can playback, which is … depressing.

I put away my HTPC about two years ago, when I was living in my previous apartment.  I moved into a place that was probably about 550 square feet.  Pretty tiny, and I liked it, but no room for a fantabulous multimedia setup.  So I sacked it for a while and was okay with that.  The fact is I actually spent more time getting it up and running and customizing it than using it.  Which is weird.  Actually I spent even *more* time ripping the DVDs and then not watching them.  But that’s okay.  It wasn’t until recently that I found a setup I think I’d like even more.

For now, I’m preferring having *less* hardware, and so just sticking a small 8GB USB thumb drive in my Blu-ray player with a smattering of samples of shows suits me just fine.  It’s no amazing thundershow of hardware and multimedia, but it *does* get me actually watching the content, so there.  I imagine if (and when) I have a house where I can properly get loud without upsetting neighbors, that’s when I’ll whip the big speakers back out and deck it out properly.  Some day. :)

In the meantime, today, I’ve been working on my DVD scripts.  I call it dart for “dvd archiving tool.”  It’s a complex set of scripts that I’ve been putting together for years, and it is highly customized for my own setup, with a CLI tool to read and access DVDs, then archive them in a database.  I also have a web frontend that I use to tag tracks, titles, episodes, etc. and so on.  If it wasn’t so unwieldly I’d throw the source out there, but the thought of having to explain to *anyone* how to get it up and running makes my head hurt.  So, if you want a good DVD ripper, here’s my advice: use Handbrake.

One problem I was trying to solve tonight was checking for these three statuses of my DVD drive: is the tray open, is the tray closed, is there media in the tray (while closed).  I have to use different tools for each one, but the problem that I always run into is this: it’s impossible (as far as I have been able to discover) to know when a DVD tray is both closed and ready to access.

The problem is that you can run eject just fine to close the tray, but once the command exits successfully, that doesn’t mean the drive can be accessed.  That is, running “eject -t /dev/dvd” and then “mplayer dvd://” in sequence, mplayer will complain that there’s no DVD device.

What’s the solution to all this?  Well, wait four seconds after running “eject.”  That’s simple, but I still spent hours today trying to find out if there was another way to do it.  While I never did (and ended up using ‘sleep’), I did find some cool stuff for polling and reading DVD devices.

blockdev

blockdev basically displays some interesting information about the block devices — in this case, /dev/dvd.  Now, for my library, one thing I have been doing lately is storing the size of the DVD in my database, so I can get an accurate number of how much HDD space I need when I want to archive the UDF or rip it.

You can use blockdev to get the amount of bytes like this:

blockdev –getsize64 /dev/dvd

Now if you want to see that in megabytes, just divide it by 1024

expr `blockdev –getsize64 /dev/dvd` / 1024

udisks

Next up is udisks, which can get information about the DVD device itself.  In this instance, I use it to see if there is media (a DVD) in the tray or not.

Running “udisks –show-info /dev/dvd” spits out all kinds of interesting information, but what I’m looking for is the “has media” field.

udisks –show-info /dev/dvd | grep “has media”
has media:                   1 (detected at Wed Jul  3 23:21:23 2013)

Now, that will say 1 *if* the both the disc tray is closed and there is something in there.  And if the DVD drive has stopped spinning enough for the command to work (again, sleep 4 seconds after closing the tray).

It will display a zero if there is no media *or* if the DVD tray is open.  Here’s a simple command to get just the number:

udisks –show-info /dev/dvd | grep “has media” | awk ‘{print $3}’

cddetect

This is an old small command-line tool I’ve used in the past.  It polls the drive to see if there’s something in there or not, and if the tray is open or not.  Sounds great, right?  It should do everything I want, solving all my problems … except that it doesn’t build on my system (Ubuntu 12.10 with gcc 4.7.2).  It used to, on my older setup, which would have been about 2.5 years ago.

It’s just a small C script, just over 500 lines, you can find it here on Freshmeat.  If someone wants to patch it to get it working, I’ll personally deliver you a plate of brownies.  Mmmm, brownies.

I actually *do* have an old 64-bit binary that I built way back when, because I kept a copy of my old development filesystem.  So I have a working blob, but it kind of breaks.  So I kind of rely on it.  I can only use it if the tray is open or if the tray is closed and empty.  So the way I check if a device is empty and closed in my script is I’ll first poll it to see if it has media with udisks, and if it doesn’t, then I’ll run this one.  If I run it with a disc in there, it pukes on me, and so I have to work around it.  It’s a hack, I know, but whatever.

qpxtool and readdvd

This is the project I ran into today, and I am super, super excited about it.  The QpxTool project is full of way cool little utilities for accessing your drive settings.  Honesty, I didn’t look at the other ones, because I was so hyperfocused on ‘readdvd’.

From the man page, “readdvd reads even a corrupted dvd and writes the the result into a new image file on your harddisk.”  This is awesome, because it’s the first utility I’ve found *specifically* for creating an exact image of a DVD filesystsem (UDF).  In the past, I’ve always used dd, but now I’m onto this one.  It skips over bad sectors and gets the image squeaky clean off of there, and I could not be happier.  This one ranks up there with Handbrake in both awesomeness and must-have-ness.  I should add that it’s also in Ubuntu’s default repos, so have fun.

Just run “readdvd -o movie.iso /dev/dvd”.  Pretty simple.

That’s pretty much it for now.  There are other great tools out there: lsdvd also ranks in the “must have” category.  I couldn’t do anything without it.

I mentioned dd earlier, and I actually use pv with it to give me a nice progress bar (also in Ubuntu repos).  It works just fine, I’ve been using this approach for years.

pv -ptre /dev/dvd | dd of=movie.iso

One more thing I wanted to mention.  Sometimes, some errors get thrown to the syslog because either an application or the DVD drive itself is being fussy.  I haven’t quite narrowed down which it is, but I’m betting it’s the firmware on the DVD drive complaining since some brands (Memorex) complain, and some do not (BenQ).  By far, the best-quality DVD drive I’ve had to date was actually a Sony BD-ROM drive.  At least, I think it was Sony.  Here’s some of the errors I get sometimes:

Jul 3 18:37:04 localhost kernel: [11955.073772] sr 0:0:0:0: [sr0]
Jul 3 18:37:04 localhost kernel: [11955.073784] sr 0:0:0:0: [sr0]
Jul 3 18:37:04 localhost kernel: [11955.073795] sr 0:0:0:0: [sr0]
Jul 3 18:37:04 localhost kernel: [11955.073808] sr 0:0:0:0: [sr0] CDB:
Jul 3 18:37:04 localhost kernel: [11955.073826] end_request: I/O error, dev sr0, sector 4096
Jul 3 18:37:04 localhost kernel: [11955.074286] Buffer I/O error on device sr0, logical block 512

To avoid issues like this, I run a small command to just decrypt the CSS on the DVD so it can kind of clear its head a bit.  Just run mplayer on it, watching about 60 frames (or 2 seconds worth of video), but just ignore it and dump it out.  The whole point of it is to decrypt the DVD, and move on with your life.  And here you are:

mplayer dvd:// -dvd-device /dev/dvd -frames 60 -nosound -vo null -noconfig all

I don’t pretend to understand how or why that helps, but I know it does.  If someone knows why the drives are doing that, I’d love to know.

The only other app I can think of right now off the top of my head is ‘dvdxchap’, which is part of ‘ogmtools’.  I know ogmtools is old, and the OGM container isn’t popular anyway (that I’ve seen), but it’s perfect for getting the chapter information out.  Although I may use something else now (lsdvd?).  I can’t remember, and I haven’t had to mess with chapters lately.

That’s it for me.  Have fun, rip away, and watch some cool Super Friends DVDs.  There are a LOT of seasons out there.  It’s great. :)

Leave a comment

Filed under bend / dvd2mkv, MPlayer, Multimedia

wrapper script for disc_id

I wrote a little wrapper script for disc_id tonight, available here. disc_id is a little binary that ships with libdvdread, or at least, it used to in older versions.

I use disc_id to give me a unique 32-character string of a DVD, so I have an identifier to track them by in my database of DVDs.

I don’t know if it’s just me or not, but my DVD drives have issues trying to poll the devices. Once I insert a disc, it will take a few seconds for it to register completely so I can access it. However, binaries that access it will think it’s ready to respond sooner than it is able, and will die unexpectedly. So what I needed was a way to get the disc id and not worry about whether or not the drive has finished registering or not.

I just call my little script dvd_id and it is simply a small wrapper that checks the exit code of the disc_id binary. If it doesn’t work the first time, it sleeps for one second and tries again, then repeats the process until it gets a successful exit code of zero.

That’s it. Pretty simple, but like all little scripts, you really tend to depend on them.
#!/bin/bash
EXIT_CODE=1
DEVICE=$1
if [[ -z $DEVICE ]]; then
DEVICE=/dev/dvd
fi

if [[ ! -b $DEVICE ]]; then
echo "Device $DEVICE doesn't exist" >&2
exit 1
fi

while [[ $EXIT_CODE != 0 ]]; do
/usr/local/bin/disc_id $DEVICE 2> /dev/null
EXIT_CODE=$?

if [[ $EXIT_CODE != 0 ]]; then
sleep 1
fi
done

Leave a comment

Filed under bend / dvd2mkv, Gentoo, Multimedia, Programming

playlist resume

I wrote about this a little bit a while back, wrt mplayer-resume, that I wanted to work on a way to resume playback from a playlist as well using MPlayer. Well, I finally sat down and figured it out last week. For some reason it took me a good while to figure out the logistics of how to do it rather than the coding. I dunno why. Anyway.

I wanted to wait to bump mplayer-resume until after I added something else, and this is gonna be it. Just gotta clean up the code and package it now, and it’ll be ready to go.

Here’s how it works though: the script, like mplayer-resume, acts as a wrapper to mplayer. In fact, everything is pretty much the same except that it saves both the filename along with the position in the playlist.

The problem I was having a hard time figuring out was that I wanted to easily make two options available: resume playback in the current file I’m in (old mplayer-resume functionality), and resume playback in the position in the playlist I’m in. I just finally mapped two keys on my remote, exit and stop, to take care of both of them.

Hitting Exit on my remote will save the playback of the current file and write that to the playlist position file. Then it also saves the seek time where I left off. Hitting Stop will kill the old entry and just add a line to the playlist saved position file that says what the *next* file should be on playback.

Pretty simple when you consider it, but it took me some time to figure out, mostly so that it seemed intuitive. I figured I’d have a hard time getting used to it, and hit stop accidentally and losing my place where I wanted to be, but so far it’s worked out fine. I’m happy with it.

I’m using it for playback of my TV shows, which is pretty much 95% of what I’ve got ripped on my media setup. I have a few movies, but no AC3 output, so I prefer to just stick those in my DVD player. It is the only way I can watch my Region 2 or 4 DVDs though. For TV, it works great, since I generally want to watch them in general succession of episode order. And if I don’t feel like watching a certain episode, you just hit stop and it’ll skip to the next one. Very nice. I suppose I could map a button to go *back* in the playlist if I screw things up accidentally, but I’m kinda running out of buttons to map on my remote. Besides, vague mappings that I’m supposed to remember usually hurt more than help.

2 Comments

Filed under bend / dvd2mkv, Gentoo, Multimedia, MythTV

bend, drip, mythvideo

Here’s something I haven’t written about in a long time — bend, my custom written CLI PHP5 scripts to rip and encode TV shows.

I actually rewrote the entire thing over Labor Day weekend.  What’s amazing is it took so long to write the original one, but so short a time to completely revamp it.  It’s something I’ve been wanting to do for a long time, and I’m glad I finally got to it.  The code on the old one was so horrible, and was such a frustrating experience to patch, debug or add features.  The new one is already 20 times better.

The first one was just plagued by scope creep, though — I started off just mostly coding it around the way that I thought DVDs *should* work and how they ought to be authored, only to be constantly slapped in the face by so many exceptions that I’d have to go back and hack it to work around the new found realities.

One example is that either lsdvd or libdvdread is buggy in how it outputs chapter information.  Actually, my whole experience with chapters have been that if there are any oddities, then the players will just freak out.  You wouldn’t believe the cases I ran into.  Anyway, here’s a small example.  On one DVD, lsdvd will report in original output that one track has 30 chapters on it.  But when you go to display the chapters, it will only say that there are two.  Most of the time, what happens, is that it will choke anytime there is a chapter between others that is zero length.  In this case, lsdvd just chokes and stops counting them.  MPlayer (at least, the ancient version I’m using) will do a couple of things depending on its mood — sometimes freeze, sometimes skip over it, sometimes act like its not even there.  It’s very odd.  I’ve found a lot of interesting little bugs in the dvd libraries and tools.  I’d love to poke and the source and fix them up … when I have time.

The code is online in my svn repo, and the new one is called ‘drip’ for dvd ripper.  Original, I know, but eventually it will replace bend completely once I add in all the features the old one had plus all the new stuff I want.  I would throw in a link to trac which has prettier display output for viewing SVN files, but my installation is broken (again) and I have no idea why, and it’s always a royal pain trying to figure out what went wrong, so I’ll just fix it later.  I love trac, but its not easy debugging the setup.

Oh yah, also I’ve been working on my mythvideo setup, tweaking it even more.  One really thing that dawned on me, which I’ll write in more detail once I actually have a script ready, is that you can use it to execute shell scripts using the File Types admin menu.  Just tell it to execute .sh files in your folders with /bin/bash and away you can go.

Another thing I learned is that MythVideo will only pass two variables to any external scripts, the default player (%d) and the video file (%s), or more accurately, the file you’ve selected to run.  So if you wanted to see what you’re executing, you would add this to the file type for .sh files: /bin/bash %s %s

Then, say you had test.sh, this would be the contents:

#!/bin/bash

echo $a

I’m getting ahead of myself, though .. I’ll write more about that when I’ve got something to show.  I’m actually working on a shell script similar to mplayer-resume to resume playback of a playlist you’re in.  It’s a bit trickier than I thought it would (or rather, not nearly as simple as I had hoped), so I’m still scoping it out in my head.

Speaking of mplayer-resume, I fixed a bug I kept running into with it for a while now.  The script will now catch the exit code of mplayer, and if it’s not successful (zero), then it won’t overwrite or delete the old position.  I used to hit it all the time because I used to run mplayer -hardframedrop when playing my videos, which would crash the playback about 10% of the time and of course kill the file that had the playback position.  I need to repackage it and push it live, but there’s a few more small fixes I want to make to it first … I might finish the playlist resume script first and add it to there.  Plus I want to get trac working, because that’s where it’s homepage is.

But, I moved my mini-itx to the living room and hooked it up to my HDTV.  It was sitting in my bedroom just collecting dust, and I figured I might as well move it to see if it gets any more usage.  Actually, I remember now, I moved it was because the LED lights were really bright in my bedroom at night, and I have to sleep in total darkness to get a good night’s rest.   Anyway, it’s worked out well so far.  My TV has a VGA port so it’s super simple to plug it in, not to mention I like the fact that it doesn’t use up an HDMI port.  I love my TV. :)  Once I have this series playlist resume script finished, I think I’ll be pretty much “done” with having the setup that I’ve wanted so long.  Well, aside from the fact that I need about 12 more terabytes of harddrive space.

Good times, I tell you what.  I’m gonna go watch some Star Trek TNG.

2 Comments

Filed under bend / dvd2mkv, Gentoo, Multimedia

mplayer-resume-1.5

A bug in MythVideo inspired me to work on fixing mplayer-resume tonight, so that it can properly handle movies with filenames.  I don’t know why I didn’t think about this before, but it’s simple if the file is properly escaped or quoted.  And so, mplayer-resume v1.5 is released, with support for spaces in filenames, finally, and also one other cool little thing: it works with playlists now, to a degree.

The playlists thing is kind of hard to explain, and it’d be easier to point you to the documentation that I’ve already written.  Instead, I’ll just describe what it is I’m going to use it for.

One thing I’ve been wanting to add to my MythVideo setup is some playlists so that I can randomly play something.  I have a lot of cartoons and videos and movies, and sometimes I don’t feel like picking something myself — one of the nice things about TV in general is you are genuinely surprised when you’re channel surfing and something cool just happens to crop up.  That’s kinda what I like, and what I wanted to do.  But, I wanted to take it a step further.  If I started playing $random_episode, then if I quit, I want to be able to resume playback of that same show.  Up until now, mplayer-resume wouldn’t work that way, since if you’re randomly picking something from a playlist file, there’s no real way to seek back to the same one.

That’s fixed now.  The script will read the filename of the movie you are playing when you exit (once you setup .lircrc correctly), and checks to see if that’s the same file you started playing.  So if I play random.pls and it plays Tarzan.mkv, and I exit, then when I go back to watch Tarzan, it will resume in the same place.  Basically, it saves the file position for Tarzan instead of the playlist file.  Pretty cool. :)

So, there you go.  I’ll put it in portage shortly as well.  Enjoy. :D

Leave a comment

Filed under bend / dvd2mkv, Entertainment, Gentoo, MPlayer, Multimedia, MythTV

preparing for dts

Now that I’ve got my mythbox all setup properly (I screwed up LVM2 and lost all my data, twice, trying to remove harddrives … meh), I’m back to ripping my DVDs again.  This time I’m using dvd2mkv, my custom little script I wrote, to do all the heavy lifting for my movies.  But, there’s one thing I didn’t really put in there the first time around, and that’s support for alternate audio tracks.

Originally I wrote it simply to check automatically for the highest number of tracks and best audio format.  As a general rule, that chooses the first channel that’s in English with 6 channels, which is always (in every case I’ve seen so far), Dolby Digital.  If there is a DTS track, it’s always the second or third track behind it, but never gets selected automatically since it’s not the first one on the list.  I can, however, select it if I run the program interactively.  Not really ideal, of course, but it’ll have to work for now.

My real question though is, why aren’t there more movies with DTS audio tracks to them?  Back in the day when I was working at a movie theater, one of my managers would swear up and down that DTS was better quality than Dolby.  He would even make the projectionist screen the movies for him in the DTS  theaters if the movie was equipped for it.  He was quite the audio and videophile so I took his word for it.  Now, though, you hardly see it anywhere.  The only DVDs I’ve seen them on are some Paramount and Fox titles, and even then it’s only the newer ones that have it.

What’s also really interesting, and I kind of assumed this, is that SDDS, Sony’s 8 channel format, is completely missing from a home theater setup.  Good ol Sony, going off and making their own standard yet again.

Anyway, when I listen to DVDs with both tracks, I really can’t tell a difference myself.  My receiver supports both DTS and Dolby, so I figure … why not, I’ll rip em anyway and see if it really is any nicer.

2 Comments

Filed under bend / dvd2mkv, Entertainment

dvd ripping scripts

I was lucky enough to catch Martin’s post on Planet Larry today about undvd, a script he’s working on — very cool, Martin, I love it.  I’m actually working on one of my own, or have been for a while, and I’ve been toying with the idea of cleaning it up and releasing it for public consumption.

I actually started writing my own because, as Martin says, all the other ones out there are too complex, and I prefer a simple command-line app that does exactly what I need it to do.  I call mine dvd2mkv, since I extract everything I want (video, audio, subtitles, chapters) and dump it straight into a Matroska file.

In fact, the script is already done, and it works great.  It automates the entire process — selects the longest video track, the widescreen one if there if full frame is on there as well, grabs the English (or preferred language track) with the highest number of channels (Dolby or DTS), plus the English subtitles if they exist, and finally the chapters.  All I have to do is put in the title of the movie, and even then if the disc ID is the title, then you can skip past that as well.

In fact, here’s the output of a movie I just ripped a few minutes ago, Return to Me.  Great movie, btw.

steve@charlie ~/dvd $ dvd2mkv
[DVD] Disc title: RETURN_TO_ME
Enter a movie title: [Return To Me]
[Video] Track number: 5
[Video] Aspect ratio: 16/9
[Video] Length: 115.79
[Audio] Track: 128
[Audio] Format: Dolby Digital
[Audio] Channels: 6
[DVD] Subtitles: None
[DVD] Ripping MPEG-2
[DVD] Ripping chapters
[MKV] Creating Matroska file

And that’s it!  Pretty simple. :)  Mine doesn’t have support (right now) for re-encoding the movies, since I’ve already gone into quite a bit of length on why I don’t like doing that, but it would be simple to add.  In fact, my shortcut method would just be to have the user setup mencoder profiles in the config file and call those directly.

Anyway, I like the idea of cleaning it up and throwing it out there, so I’ll probably be doing that fairly soon here.  If it works good enough for me (picky as I am), it’s sure to help out someone.  :)

3 Comments

Filed under bend / dvd2mkv, Gentoo, Multimedia

dvds, cartoons, audio tracks and matroska

The bug has once again bitten me to get all my multimedia on demand, even though it is an enormous time-consuming and costly process. This is probably round three or four for me trying to do this. This time around, things are a little different. Instead of ripping and saving everything from my entire collection, I’m going to try and just archive the stuff that I consider a novelty, or any cartoons that are short in nature. I’m doing it as a bit of a test run for a couple of reasons — to see how much time it will take, to work out a few bugs in the system, and to find out if I’ll actually bother watching anything.

So, right now, I’m working on both Looney Tunes and all my Walt Disney Treasures DVDs. Even that stuff alone is going to take up a massive amount of space, since I don’t re-encode the video (read archives for why, long story) or audio. Right now, Ive only got a little over 500 gigs to spare, with close to another terabyte that I can slap in if I think this is going to work. In the end, I’m going to have to buy either 750g or 1tb harddrives to hold everything, but I’m trying not to think about that just yet.

Anyway, onto the joy of ripping, encoding and muxing. I’ve dregged out my old dvd ripping project, bend, and dusted it off and started poking at it again. I can’t believe how much work I put into this thing to start with, it works *amazingly* well if I do say so myself. It makes ripping and archiving TV shows on DVD incredibly simple. I only had to add on a few small features as issues cropped up with my new goals.

First of all, I had always had it hard-coded to re-encode the video to MPEG4. In the database, I had an option to leave it alone as MPEG2, but the code wasn’t using that. So, I added that and set the default to not re-encode. The next problem I ran into was that on the Looney Tunes discs, I found some tracks that multiple audio tracks: both different languages and commentaries. This would cause problems because when you rip the VOB from the DVD to the harddrive, I use mplayer along with -dumpstream -dumpfile, and it snags all the audio tracks. Using that method, there’s no way to single out just one audio track (to be more specific, passing -aid 128 or -alang en doesn’t do anything). The only way to do that is to actually re-encode the video (or audio) and specifically select the audio track, which I don’t want to do, since it causes A/V sync issues on cartoons because of variable framerates.

To solve the problem, I poked around at Matroska and the mkvmerge tool a little bit. I had remembered seeing once that you can tell it which audio tracks to use when creating a new video file. Finding the track ids is simple, just run “mkvmerge -i” on the MPEG-2 .vob file. Here’s a sample output of one with multiple tracks:

steve@flick ~/media/dvds/Looney_Tunes $ mkvmerge -i season_1_disc_4_track_15.vob

File ‘season_1_disc_4_track_15.vob': container: MPEG 2 program stream (PS)
Track ID 0: video (MPEG-2)
Track ID 1: audio (AC3)
Track ID 2: audio (AC3)
Track ID 3: audio (AC3)

Now, you’ll see there’s only one video track, so that’s not a problem … matroska will just use that one by default. But since there are three audio tracks to choose from, it also uses the default, being the first, which is always another language or a commentary track (so far). In fact, my experience has shown that in every case where there are multiple audio tracks, it’s always the last one that I want. There have been some corner cases on a few individual episodes where that rule of thumb doesn’t apply, but it’s been something like one for each disc, which would be something like one out of every 15 to 20 episodes. As a matter of QA, I have to individually go back and play each muxed video to make sure the default of using the last audio track was what I wanted. Slightly time consuming, but not really a big deal, and I don’t know of any other way to get more details on which audio tracks are which. It just occurred to me that I should probably look into using mplayer with some verbosity flags. Oh well.

Another problem I ran into was that mkvmerge itself is picky as to the order of passing arguments. If I didn’t do things in the right order, then all the audio tracks would be selected. Kind of annoying. I vaguely recall reading something about that in the man page before, but I didn’t bother looking through there again. Instead, I figured up mmg, the wxwindows GUI to mkvmerge and watched how it did it. For the record, here’s a sample of a correct execution:

$ mkvmerge -o foo.mkv -a 2 season_1_disc_1_track_3.vob

In that example, the -a argument is for the audio track, followed by the number.

I also changed the database around, adding a new table called ‘episode_tracks’. When I rip the DVD for the first time, bend will check the number of audio tracks, and store them in the database. On the web frontend, where you edit the track titles, I also added an option to select the audio tracks on a per-episode basis. You can also set the default track # for the entire disc, if you want, to change all the episodes at once.

I should note that in all the DVDs I’ve seen, Looney Tunes seems to be an exception to many rules. Most DVD series aren’t even going to have multiple language tracks or commentaries. And even if they did, I don’t think they would have so many. I’m just glad that I happened to use this one first, so I could get the workarounds coded.

Something else I changed in the code, when muxing into Matroska, is I now pass the –title call along with the series and episode titles, so that they get written into the container as well. I’m not sure if I can get MPlayer to display that, but it might be kind of nice sometime if I wanted to recall what the title was, and just hit a button on my remote — I wouldn’t have to do something funky like check the filename, instead it would just be all right there.

Here was something else that was funky. My DVD drive in my desktop box was having issues ripping discs with MPlayer. I was getting some IDE error messages like this:

Buffer I/O error on device hdb, logical block 20278
Buffer I/O error on device hdb, logical block 20279
hdb: media error (bad sector): status=0x51 { DriveReady SeekComplete Error }
hdb: media error (bad sector): error=0x30 { LastFailedSense=0x03 }
ide: failed opcode was: unknown
ATAPI device hdb:
Error: Medium error — (Sense key=0x03)
(reserved error code) — (asc=0x11, ascq=0x05)
The failed “Read 10″ packet command was:
“28 00 00 00 4f 36 00 00 02 00 00 00 00 00 00 00 “
end_request: I/O error, dev hdb, sector 81112
Buffer I/O error on device hdb, logical block 20278

First, I looked at my kernel to make sure my config was okay, and I flipped on a few more generic flags to see if that would help, then rebooted into the new kernel. It didn’t do anything. The drive would read for a few megabytes, then freeze on some titles. It seems like also it wouldn’t matter which track or disc it was on … it would just poop out after a certain amount of ripping.

I thought about heading down to PC Club and dropping $50 on an SATA DVD burner, thinking that having a drive that didn’t use IDE in the first place might be the solution. I can’t afford to buy more hardware right now though, so I kept poking around. At the same time, on the Walt Disney Treasures DVDs I was ripping (Tomorrow Land rocks, by the way), a lot of them have introductions by Leonard Maltin. I’ve got nothing against the guy, but I certainly don’t want his or anyone else’s face on my screen telling me what I’m about to see and then showing off the coolest scenes right before I’m going to watch them. So, I had to add another option to dvd-bend to let me say which chapter I wanted to start the ripping at. Incidentally, once the code was finished, I tried it on my desktop … and my IDE issues went away. As a result, I went ahead and hard-coded it as well to default to add ” -chapter 1 ” to the mplayer dumpstream command (if none was specified) so that my drive would always work. So far, it’s done great — no more ripping issues.

Once again, just for the record, here’s what I used as a workaround to my faulty drive to properly rip a DVD track:

$ mplayer dvd://3 -dumpstream -dumpfile track_3.vob -chapter 1

That’s pretty much it so far, as far as changes. That alone didn’t take too much time at all, just a few hours. I’m still working on setting up subversion on my live server so I can share the code if anyone wants to look at it. In the meantime, here’s the output of bend as I add a new series to the database, and rip it, so you can see how it works

Leave a comment

Filed under bend / dvd2mkv, MPlayer

download mplayer-resume

It’s far from glamorous, but I’ve setup a directory where you can download the latest version of mplayer-resume, in all of its 2.7k glory! Sweet.

I also submitted the “project” to freshmeat, so hopefully that will give it a little added exposure. I searched high and low for a solution, so I know how hard it can be to find something like this.

Downloads are available here: http://spaceparanoids.org/downloads/mplayer-resume/

Oh, and for the record, the documentation is included as comments in the code.

Leave a comment

Filed under bend / dvd2mkv, Computers, MPlayer, Multimedia

absolute insanity

Uncle Scrooge always had a great saying that he said someone taught him — “Work smarter, not harder.” Gosh, I still remember that Duck Tales episode from fifteen years ago or so. Now that’s crazy.

That’s what I’m doing though — I’ve gotten my encoding settings finalized, I’ve scrapped all my old encodings, and now I’m ripping everything in a nice organized little manner. Right now my floor is a huge mess, with DVDs literally everywhere, as I’ve got them stacked in piles and divvied out to three computers to rip and encode.

The other day, I quietly changed the backend class and switched the main encoder from transcode to mencoder. The main reason is that mencoder can handle variable framerates just fine, of which more than 90% of these DVDs are. That, combined with pretty much the same filters and settings I was using on transcode, the end results looks really, really nice. Every sample I’ve watched so far there has been no stutter, no weird skips, no odd artifacts. In fact, I’ve though to myself, “wow, this looks just like the DVD.” They are that smooth, so I’m very happy.

For the record, here’s my encoder settings I’m using on most all of my TV DVDs:

mencoder foo.vob -o bar.avi -ovc xvid -xvidencopts bitrate=2200 -oac copy -vf pullup,softskip -ofps 24000/1001

Pretty simple, huh? The only drawback is that I like the new settings so much that I scrapped every encoding I’ve done up to now except for a few shows. That was a lot of time down the drain, but I have a new system now which has helped me quite a bit to do this much quicker.

One thing I did is I divvied up all the discs between my three amd64s, and there are stacks all over my living room. This way I don’t have to hunt down a box or remember what’s next. When the tray pops out, I just stick the next one in, and start that one up. Right now I’m ripping about three discs every 15 minutes.

The other idea I had that I like a lot is I took a sample track from each series, and dumped it to a folder where they won’t be ovewritten. With those, I do all my encoding testing, and that’s how I found out those mencoder settings above really do work on everything I’ve thrown at it so far. Especially the cartoons, those look gorgeous.

The encoding is gonna take some time, that’s for sure. I just counted, and theres 18 more DVDs to rip, and *then* I’ll be halfway done with ripping (I haven’t even started on the live-action shows yet). My queue manager says my estimated encoding time is currently 142.34 hours. Yeeks.

Leave a comment

Filed under bend / dvd2mkv, Computers, MPlayer, Multimedia, Transcode