147 episodes a day

Much to my surprise, I had a few people ask me how my encoding adventures were coming along.  I wrote a blog post earlier about it, but I didn’t like it that much, so I set it to private.  I just set it back to published, because I’m too tired to think of something coherent to share and it also includes my magical mencoder settings I decided on.

Following up on that last post though, things are going really well.  These poor machines have literally been encoding non-stop for a couple of days now.  Maybe even a week, I’m not sure. When I went to bed last night I remembered I had 450 episodes to encode.  When I started writing this post, it was down to 303.  I’m only doing the cartoons right now though, so the length of most of these episodes is either 7 minutes or 22.  It seems like it’s going pretty fast.  I would try and do the math, but that wouldn’t work out too well.

After this I have to re-encode all the live-action shows that are variable framerate as well.  I’m a little nervous testing on those, because the results haven’t been nearly as positive as it has been on the cartoons.  I really cannot say enough on how nice those look — the picture is really clear, and I seriously cannot tell that it’s a ripped copy.  One of the nice things about forcing the output fps, is that mencoder doesn’t screw around with the video bitrate, so I really am getting about 2200 kbps this time.  Before, if I left them to encode to 29.97, it would drop to around 1700.  I think that extra 500 or so has a lot to do with the quality.  They look really good.

i'm only happy when it rains

I woke up this morning, and it was raining. I love the rain. It’s one of Mother Nature’s nicer way of cleaning things up. It makes the air nice and cool, and there are breezes that just make you feel great. I love it.

It got me thinking about how it might be a time for a change, too. I’m thinking about moving. Seems like it’s time for a change, and Utah doesn’t really feel like it fits me. It never did feel like it did, really. For one thing, I can’t relate to you guys too well (I grew up in Missourri, Indiana and Georgia … things are quite different here).

So, now I’m thinking about moving on, learning something new, trying something else out. If I had my way, I’d love to live in Europe. But I’ll probably stay in the States. Ideally, I’d like to move to either the Northwest coast or New England. I hear it rains a lot there.

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.

aspect ratios

A comment on yesterday’s blog entry got me thinking and doing some research about how the aspect ratios work, and something finally clicked. I finally understand how it works. :)

The video aspect ratio isn’t just a simple calculation of height/width, it’s the ratio at how you want the playback displayed. Fullframe is 1.33:1, flat is 1.85:1 and scope is 2.35:1. It all makes sense, now. I didn’t need to scale my videos down to 640×480 to force the resolution to 1.33, I just needed to either tell mplayer to playback at a different aspect, or fix Matroska so the aspect ratio was correct. I ended up doing the second one.

Turns out it wasn’t (necessarily) a bug in mkvtoolnix, just me not passing in another option. Actually, I didn’t even know about it tell I looked at the man page some more. Turns out there’s an –aspect-ratio flag you can use when setting it for different video streams (have I mentioned that Matroska can hold multiple video and audio streams? To say nothing of attachments, chapters, DVD menus and subtitles … why are you still using AVI?). By not setting that flag (this is where I think the bug is) it defaulted it to 1.5, even though the AVI had it set at 1.33. Using the argument –aspect-ratio 0:4/3 fixed everything though. And I don’t have to rescale my video anymore, I’m glad about that one.

rambling about encoding

Well, I’ve finally settled into an encoding configuration that is presentable enough to use on most everything. It’s not the best, but it’s acceptable, and looks good on my TV, and I’m tired of not doing any encoding lately … so I’m going with it.

I actually did end up using mencoder as the default encoder instead of transcode. Well, it’s the default anytime there is something odd like variable framerate or transcode just can’t get it quite right. If the framerate is standard on it though, I run a two-pass encode on transcode instead.

I actually did run into a funky bug either with mencoder or mkvtoolnix (Matroska tools), but I’m not sure which one it is. The DVDs are encoded at 720×480 resolution, or a 1.5 ratio, but whenever I would encode them … mencoder would save them as a 1.33 ratio. The AVI would play fullscreen, but when I wrapped it into Matroska, it probably used the incorrect ratio, and rescaled it on playback so now I had black bars at the bottom and top.

I tried using -vf dsize=1.5 for a quick hack with mencoder to force it to 1.5 instead of 1.33, and I could have sworn that worked, but when I tried it later it wasn’t. So, instead, I’ve resorted to the less friendly but still functional option of rescaling the video to 640×480 instead. Not really a big deal since I’m not moving it around that much, but still not desirable. I think that’s probably the reason now that transcode would chop off a few pixels on each side when encoding, was to make sure that the aspect ratios were correctly calculated. I guess.

Another thing that’s interesting is that I could rescale it down to 320×240 if I wanted to. I’m not sure, but I think that’s what my television’s highest resolution is anyway (no HDTV for me). The video looks just as good, as far as I can tell. The only problem (there’s always something) is that mencoder always chooses to ignore my bitrate options that I’m telling it to use (2200) and encodes it at 700 kbps instead, which is pretty annoying. Even at 2200 and rescaling to 640×480, it still only encodes at around 1800. I don’t know what’s up with that. I was looking at the mailing lists yesterday, and I couldn’t find any way to force mencoder to use CBR with XviD. Bleh. Another reason I prefer transcode, right there. I eventually did find out though that you pretty much have to either double or quadruple the bitrate in your config file or arguments for it to actually downgrade to where you really want it.

I’ve also started playing with some video filters on mencoder. The cartoons still look much better with transcode, but that’s most likely because I’m passing it through three filters. Right now I’m trying to find the mencoder equivalents. It’s not all that big of a deal though, and I’m just glad I’ve found something that gives pretty good acceptable quality for now. The live-action shows are easy to encode, its the cartoons that you really notice the problems because of all the action and the cool colors. I’m planning on coming back to doing more research when I’m all finished encoding, but for now I think I’m finally set. :)

so, did I just waste another three weeks of research?

I’m still doing testing on what works best for what series so I can rip and encode them all (which, there is an awful lot), and tonight I started playing around with mencoder. The thought occurred to me … why don’t you just use that instead of transcode?

Um. That’s a good question.

One of the cool things about mencoder is I don’t have to worry about selecting the AC3 track, I don’t have to worry about variable framerates, I don’t have to resize, crop, filter, post- or pre-process the video for it to look good. In fact, this is *all* I have to do:

mencoder dvd_track.vob -o xvid.avi -ovc xvid -xvidencopts bitrate=2200 -oac copy

Compare that to the average tests I run using transcode.

So, why don’t I use it? I honestly don’t remember.

I think the main reason is probably the same as for using Gentoo. Why use the pansy tools that do all the work for you when you can spend all your free-time figuring out for yourself what the heck you need to do. Besides, you get to learn new terms like “telecine,” “deinterlace” and “3:2 pulldown.” There’s a certain grace to learning how to use something that confuses the crap out of you, and you can use it later to impress other people and sound like you know what you’re doing all at once. It’s great.

I just ran an xvid one-pass encoding on the trickiest DVD set I could find, and mencoder handled it with flying colors. Am I gonna switch? I dunno yet. I might add a “meh, this is too hard to figure out how to encode, so use mencoder and forget it” flag to the database, but that’s it. I’m enjoying the four extra db columns just for tweaking the transcode settings. :)

more fun with framerates

Well, I found a way to convert a video from variable framerate to a standard one, and it’s actually pretty simple. Not only that, I found the example about it on transcode’s wiki entry for Matroska. Obviously the last place I would have been looking for it, since I know all about those two things, right? :)

The wiki says to pre-process the video with mencoder, by forcing the output fps to a certain rate. The command is simply something like this:

mencoder input.vob -ofps 24000/1001 -oac copy -ovc copy -o output.avi

That’s copying the audio and video directly, but dropping frames on the segments that are not 23.97. You would think that this would drop a lot of frames, but from most cases I’ve seen so far, there are only a few segments where it jumps back to 29.97, so it turns out pretty well, and the video looks good. There’s only a few problems, though.

First of all, mencoder doesn’t (or can’t, I’m not sure yet) create an AVI index in output.avi, so you can’t seek the file at all. You have to rebuild it first:

mplayer output.avi -saveidx avi.idx

That will do two things: build the index before playing, and use it while playing. Another way to play the file later is to load the index while playing the file:

mplayer output.avi -loadidx avi.idx

Then you can seek again.

The second problem is that it’s visibly noticable that you are dropping frames. On playback there are weird black blocks that show up when you do any kind of seeking. A small pain, I know, but that’s the price you pay. It’s really not that annoying, actually. My bigger concern is the index.

I’m playing with ways to get both fixed at once, and I’m hoping that transcode will either re-index the AVI and/or cleanup the funky blocks. Now that the video is all the same framerate, at the very least it won’t have any A/V sync issues. That’s the great part.

Another option is to get mencoder to somehow rebuild the index, but I’m going to have to do some research to find out that stuff. While I started on that though, I did find this great documentation on how to deal with progressive framerate video. Essentially, it looks like I’m on the right track. The bummer part is that there’s a little more to it than I thought, and I might have to do research for each TV series to see how they are encoded, as far as telecine and interlacing goes.

Either way, all this research boils down to one simple principle that I keep harping on: there’s really no solution that is going to work for every video you throw at it. You can come close, of course, with some generic encoding options that will fix 90% of what you have and make it viewable. But if you want best results, smallest filesize, and cleanest video, you’re just going to have to do some research. Personally, I think it’s worth it.