playing with x264

There’s a couple of reasons I don’t encode my video.  One of them being that, everything I encode myself, I can just notice the drop in quality.  However, with the right parameters and the right codec (x264) I can get it looking really nice, and I can hardly notice a difference.  It comes at a bit of a tradeoff, though.

Here’s a snip of a sample ffmpeg output I generated last night:

$ time ffmpeg -y -i movie.vob -r 30000/1001 -acodec copy -croptop 60 -cropbottom 60 -s 720×480 -aspect 16:9 -deinterlace -vcodec libx264 -vpre hq -crf 15 -threads 0 movie.mp4

FFmpeg version SVN-r20371, Copyright (c) 2000-2009 Fabrice Bellard, et al.
built on Oct 25 2009 14:09:56 with gcc 4.3.3

Input #0, mpeg, from ‘movie.vob’:
Duration: 00:29:43.93, start: 0.280633, bitrate: 6492 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720×480 [PAR 8:9 DAR 4:3], 9000 kb/s, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
[libx264 @ 0x1c64530]using SAR=32/27
[libx264 @ 0x1c64530]using cpu capabilities: MMX2 SSE2Slow
[libx264 @ 0x1c64530]profile High, level 3.0
Output #0, mp4, to ‘movie.mp4’:
Stream #0.0: Video: libx264, yuv420p, 720×480 [PAR 32:27 DAR 16:9], q=10-51, 200 kb/s, 30k tbn, 29.97 tbc
Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s

Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=43411 fps=  7 q=-1.0 Lsize=  767982kB time=1783.95 bitrate=3526.6kbits/s

real    103m29.692s
user    155m46.121s
sys     8m0.649s

Which brings me to the second reason I don’t encode stuff … time.  Seven frames per second, on my fastest box at home, heh.  For a 30 minute video, it took a very long time.  The video looks great, though.  I can still notice a drop in quality when there is text or titles on the screen, but that’s the exception.  The size was almost exactly 50% the original (1.4 GB to 750 MB).

The backstory for this particular video though, was that it was presented in letterbox, and I wanted to re-encode it so I didn’t have to make a pan & scan config for just that file on my box.  So, I cropped the black bars off the top and bottom and resized it.

One small annoyance I have, is that all DVD source video always shows up as 59.94 frames per second when being probed by ffmpeg, and I have no idea why …. every single one of them does that, and it drives me nuts, since all the NTSC DVDs are going to be 29.97 or variable frame rate.  So, I have to specify to encode the new video to 29.97, otherwise, it will encode it to 59.94 by default and nearly double the size.

Also, I’m only doing a one-pass video encoding, ironically because I don’t like waiting.

I have little interest in encoding my video, because my boxes are so slow, but at a savings of 50% in storage space, the idea always keeps me curious.  Unfortunately, because I’m so picky about quality, it takes a long time to find something that I like, and even longer to encode everything.  On top of that, I have little to no interest in buying a faster computer right now, so I just kind of shrug the whole thing off.

I can’t deny that the video looks very nice, though.  Kudos to x264 and ffmpeg. 🙂

2 comments on “playing with x264

  1. lefty.crupps

    Your videos are listed as 59.94 FPS because thats roughly double the NTSC standard, 29.97; with this doubling comes higher-quality video. Check out info about Progressive and Interlace scanning methods.

    For very good video encoding with an easy, text-based ‘wizard’ that walks you through some encoding options and runs on its own after that, check out xvidenc and h264enc (both are available in Debian’s repositories, not sure if in Free or non-Free though). Generally I will set it up to run over night or all day at work, since a backup of a 4.2GB DVD will take about 8 hours with the settings that I pick. Launch the app in a terminal with:
    shell$ xvidenc -2p -p ehq
    meaning, 2pass, -preset ‘extra high quality’. There are other options as well if you run ‘xvidenc –help’.


Leave a Reply