Archive for the ‘bend / dvd2mkv’ Category

another update

Sunday, June 25th, 2006

I only worked on ‘bend’ a little bit today. The main new feature is that ripping works 100% now, and I’ve cleaned up a lot of old bugs. Encoding is the last thing left, and then I can finish up dvd2mkv.

One interesting little feature I added is that now you can rip the same disc in one or more session at the same time. Something I don’t recommend in the least, since it increases the disc readtime quite a bit. However, sooner or later, I’ll have it so you can pass bend –rip in one shell, and bend –rip –dvd_device /dev/dvd1 in the other. That can come in handy if you have more than one DVD drive and want to rip more stuff at once.

big changes

Saturday, June 24th, 2006

I’m a little tired. I ended up working on bend all day today (check out the huge changelog, I just checked it in). I got a lot of good stuff done though, and learned lots too.

I’ve done a rewrite this time with the whole interactive mode in mind. At first it got really tricky because I was having problems accessing stdin within a loop. The code wouldn’t wait for the user input, it would just keep going. Turns out that using handles to open and close it were the culprit, so now I just do $foo = fread(STDIN, 255); The php manual has a really good introductory chapter that covers that stuff (like say, important constants). It helped me get over the rough spots.

Another interesting part of the code is I’m using do … while control statements, which I’ve never had to use before. In this case, I need them because I can’t let them continue until the input matches a certain string or valid entry. Pretty interesting approach.

The code is coming along. I’d say its about halfway done overall, but the second half is going to be a snap since I don’t need to replace hardly any of it. I’ve got it setup so you can “archive” a disc. That doesn’t sound impressive at all, but the hard part was that all of it is completely driven by the user interface *and* you can do it either interactively through the console questions or with the argument flags. I like it. :)

All the other stuff is really simple, since it’s just a matter of rip track foo to location bar and encode with options x and y. All the settings are already in the user’s config file, and the functions are already working great, so it should go really fast from here on out. I’d just like to be able to use it again soon so I can watch some Brady Bunch.

cleaning up old code

Friday, June 23rd, 2006

I’m working on my ‘bend’ script tonight, cleaning up some old code that’s been irking me. Ugh. This is one of those projects that it would have gone a lot smoother if I had put all my pseudo code on paper first. Naturally, all my real planning is done at work while all my enthusiastic creativity is used at home. There’s gotta be some way to combine the two. Maybe I’ll reward myself in Twinkies for a good OSS program done right. :)

So, right now, I’m working on *simplifying* everything. I’m dumping everything in the class, making the functions more basic (doing one tiny thing) and other horrific “what was I thinking” code cleanup. Someday I’ll get a release out the door.

In the meantime, I just added a tiny still-not-perfect function I wrote to pull in options from stdin:

$ bend --rip   --debug
Your DVD is not in the database.
Would you like to archive it now? [y/N] yes
string(3) "yes"

Pretty funky … at least, I think it’s cool writing PHP shell scripts that are interactive. This certainly deserves a Hostess-brand sponge cake reward.

new trac setup

Sunday, June 11th, 2006

I setup a new trac project for bend: http://wonkabar.org/bend I included a very mini howto on the wiki if you want to try it out — dvd2mkv, at least … bend would be far too complex and confusing right now. Just download the two php files from the browse source page, and make sure you have all the dependencies.

Getting the trac frontend online is going to help a lot … at least now I can file bugs for myself so I don’t have to remember what else I need to get done. Maybe that’ll light a little fire under me at the same time. :)

bend / dvd2mkv madness

Sunday, June 11th, 2006

You know you’ve been neglecting your pet project for a while when you try to run it and your system is missing one of the required libraries. Whoops.

Just yesterday I found a program that is going to help me a lot with the project. Ogle to the rescue, again. libdvdread comes with a binary called ‘disc_id’ which gives a unique identifier for a DVD. That is a godsend, since my way of getting a “unique” identifier for the discs was to read the disc title and then check it against a regular expression pattern in my database of possible values for titles. Needless to say, a 32 number hash is much simpler.

So, I’ve started plugging away at it again. It’s safe to say that this little script needs a lot of work. But in its most basic form, it works perfectly well once you get it setup. The backend is a still an utter and complete mess though. I’ve gone from writing it in a class to procedural back to a class. Oy. And I haven’t commented things very well, and it’s very confusing when I try to find why something’s not working right. I’m still really excited about it though.

I think one main thing I need to do (besides actually publically releasing it) is get a little text interface going, similar to nuvexport. That way you won’t have to do something like bend –archive –title “Malcolm in the Middle” –rip –encode. I’ve also thought about rewriting it in bash, but it’d be a pain the arse right now, since I don’t know any bash programming. It would cut down on the very strict level of dependencies though — right now it requires PHP 5.1.0 and PostgreSQL. Ah well. Someday. :)

dvd2mkv magic

Tuesday, January 24th, 2006

My little dvd2mkv script is coming along. You can actually pop in a DVD, run the script and come back a few hours later and you’ll have a nice shiny Matroska file complete with chapters and all. I’m actually pretty proud of it, even though there is still a lot of bugs, and you can’t do the main feature I wanted yet, which is to queue movies.

The good thing though is that it’s down to mostly fixing bugs and fixing code far more than it is adding features and just plain getting it to work. That’s a good milestone, I’d say.

One thing I like a lot about it is I’m just plain learning to write some better code. This is my first really interactive php shell script, and writing the backend, I keep finding better ways to clean it up and make the code tighter.

Just running an interactive script by itself is very cool. I was really surprised when I found out how easy it was.

The hardest part in all of this has been the transcode arguments. Actually, the first 85% or so of it was really simple, using dvd::rip as a reference and then reading up on the excellent transcode man pages. Transcode comes with some really good tools, and I still prefer it over MEncoder even though it (mplayer) would make things generally *so* much simpler. For instance, I already prefer tcprobe to midentify as getting me some really good valid data. That’s not a fair comparison, I know, since they both return different types of data. I’ll probably end up using them both. Right now I rely heavily on them both. Mplayer to rip the VOB, transcode to encode it to an XviD, and in the future tcprobe to make sure I’m doing things right. :)

Good stuff.

bend and dvd2mkv

Tuesday, January 17th, 2006

I’ve been working on bend a lot lately (my PHP script to rip DVDs), and am taking a break to work on a different script — dvd2mkv.

dvd2mkv will basically be a somewhat interactive PHP script to rip a DVD, do a two-pass encode and dump the whole thing into a Matroska file.

Anyway, working on it the other day I got some code working so I could have a .bendrc file in normal rc file fashion, that is param=value, and wrote a function parse it too. Here’s that:

function parseConfigFile($file) {
$readfile = file($file);
$readfile = preg_grep(’/^\w+=(\w|\/)+$/’, $readfile);

foreach($readfile as $key => $value) {
$arr_split = preg_split(’/\s*=\s*/’, $value);
$arr_config[trim($arr_split[0])] = trim($arr_split[1]);
}

return $arr_config;
}