Month: May 2007

FFmpeg Quality Comparison

Flash video is so great.

Anyway I used to use MediaCoder to convert to flash video, but when it gave me errors, and refused to tell me the specifics of those errors, I took it old school to the command prompt with FFmpeg (which MediaCoder uses anyway). This gives you a lot of useful info about the source file you’re encoding, such as audio sampling rate, frame rate, etc.

Wanting to find a balance between picture quality and streamability, I began encoding a short length of AVI video at different compression levels. FFmpeg calls this “qscale” (a way of representing variable bitrate qualities, much like LAME‘s -V parameter), and the lower the qscale value, the better the quality. The available qscale values range from 1 (highest quality) to 31 (lowest quality). Going worse than a 13 qscale produces unacceptably poor quality, so that’s as low as I went for the purposes of this test.

I encoded 3:14 minutes of an AVI, resizing it to 500Ã — 374 pixels, and encoding the audio at 96kbps and 44.1KHz, which sounds fine, and is a negligible part of the ultimate file size, so going lower wouldn’t be very beneficial. Plus I find that good audio can create the illusion that the whole thing is of higher quality. Poor audio just makes it sound like “web video.”

Here are the results, courtesy of Google Spreadsheets:

FFmpeg quality vs. filesize chart

The filesize, of course, goes down as quality goes down. And the loss in filesize also decreases, not just in amount, but in percentage as well, as indicated by the red line. For instance, the value of the red line at qscale 3 is 33.97%, which means that in going from qscale 2 to qscale 3, 33.97% of the filesize is shaved off.

However, because these losses are not perfectly exponential, I knew that there had to be qscale values that were more “efficient,” in a sense, than others — values that, despite being high, and causing a lower change in filesize than the previous step in qscale, still caused a comparably large change in filesize. For instance, still looking at the red line, you’ll notice that going from 2 to 3, as I said, shaves off 33.97% of the filesize, while going from 3 to 4 only shaves off 23.93% of the filesize; and that is a 29.56% decrease in change-in-filesize, which is a relatively large cost. We want the change-in-filesize to remain as high as possible for as long as possible.

Now, if you follow the red line from 4 to 5, you’ll see that that’s a 20.32% loss in filesize, which is pretty close to our previous 23.93% loss in filesize in going from 3 to 4. In fact, we’ve only lost 15.09% of change-in-filesize from the previous step. So these are the values we really want to examine: change in change-in-filesize, represented by the orange line.

This is nowhere close to exponential, nor does it follow any predictable decline. It darts around, seemingly at random. And we want to catch it at its lowest values, at points that represent changes in qscale that were nearly as efficient as the previous change in qscale. So the most desirable qscale values become, quite obviously, 5, 9, and 11.

What this means is that if quality is your primary concern (and you’re not crazy enough to encode at qscale 1), go with 5. qscale 5 turns 3:14 minutes of video into 30.62MB, which requires a download rate of 157.84KB/s to stream smoothly. qscale 11 will give you about half the filesize, and require a download rate of 77.37KB/s. But, because that’s the level at which picture quality really begins to suffer, and because most people don’t really mind buffering for a few seconds initially, I’m probably going to stick with qscale 9, whose videos take up 91.58 kilobytes per second, and which is by far the most efficient qscale anyway, with only a 4.92% change in change-in-filesize.

One caveat: This whole examination presupposes (as far as I can tell) that if it were possible to measure and chart the changes in the actual perceived visual quality of videos encoded at these qscale values, the curve would be perfectly geometric or exponential, with no aberrations similar to those above, and with all extrapolated delta curves showing no aberrations either. Given that, it might be easier to believe that every step you take through the qscale is of equal relative cost, and that there are no “objectively preferable” qscale values. But that is a lot more boring.

25 Responses

Conan Xmas: 2000

Tom Hanks celebrates Christmas on Conan in 2000. This has been documented as the last funny thing Tom Hanks ever did.

Miraculously retrieved from the land of forgotten television moments, four months after my plea on a Conan forum, to replace the taped copy I lost years ago. Because I like to hoard things and save them forever (ahem), I’m always disappointed when the internet fails to be effective in dredging up even the most insignificant cultural minutiae from the past. I’m getting used to it, but in the meantime, this was a warmly reassuring moment in my life.

2 Responses

Kirk Cameron, and stealing video from abcnews.com

Last weekend Kirk Cameron and Ray Comfort debated some smug atheists over the existence of God. Kirk’s and Ray’s claim was, to paraphrase, that they could prove, 100%, scientifically, the existence of God, without invoking faith or the Bible. The atheists were to prove, not that God doesn’t exist, but that Kirk and Ray can’t prove otherwise. The debate took place on Saturday night and was taped to be streamed on abcnews.com the following Wednesday and Thursday, with select portions being televised on an episode of Nightline.

Here’s Slate on the subject:

First, I grew excited at this promise, then began to wonder why no theologian, philosopher, or sitcom star in recorded history had done it before—Thomas Aquinas, Immanuel Kant, Tina Yothers, whoever—and realized I was in for a letdown. Comfort’s cadences were not even those of a preacher but of an infomercial host, and the God Squad had but three arguments on behalf of the big guy: All things have makers; the human conscience is evidence of a higher moral power; if you read the Gospel, then Christ will be revealed to you. For reasons too stupid to type, this was not an airtight case, and the atheists made quick work of it in tones of juvenile sarcasm.

They also threw in the first mover argument, which technically differs from the watchmaker argument. The content of the debate is of almost no interest, of course, as it closely parallels countless conversations that have taken place before it. But its being presented by ABC is significant, even unprecedented by recent standards of network television. Which isn’t to say that religion and God are never mentioned on TV, but that when they are, they are dismissed as irreconcilable, deeply personal things that don’t invite inspection beyond that of the effects they have on people’s behavior. They are approached as moral and cultural issues — never as metaphysical ones. And the idea that a large-ish portion of the American public might see people earnestly discussing the nature of infinity and causality, even if ineptly, only hours after Ugly Betty, fascinated me, despite my confidence that none of it would be illuminating, and that it was a ratings stunt.

I didn’t see the “distilled” version on Nightline, and the YouTube videos were removed before I could watch or save them, but I hear they did a pretty bad job with the material. At the moment, the entire debate is still available at the story’s ABC page, but, knowing that they probably won’t last, and with a tendency toward obsessive archivism and a disdain for ABC’s intractable flash player, I collected them myself. Altogether they’re about 97 minutes. If you’re short on time and have to be choosy, watch the “Mocking Darwin” segment, which contains the most lolz, and a guided, pictorial tour of an understanding of evolution so profoundly misinformed that even Lamarck is rolling his eyes. And he’s dead. As I watch this debate, I keep expecting Kirk to break character. Then I think, Ray must have some dangerously compromising photos of him.

From the Columbia Journalism Review:

We could go on, but why? Nightline felt no responsibility to take the issue seriously enough to include, say, a scientist or a theologian in the debate, so other than pointing out the dumbing down of the national conversation, we’ll just leave it at saying that we expect more of Nightline, and the American people deserve better than being forced to endure half-baked publicity stunts dressed up as news.

Thrown in at the end are some recent discussions Bill O’Reilly has had with Kirk Cameron and Richard Dawkins, in which Bill presents his own fucked version of an anthropic argument, expressing amazement that we could have “lucked out” by having such a habitable planet land on us, and plenty more frustratingly nebulous reasoning for your teeth-gnashing pleasure.

The videos were recorded using a years-old tool that I’ve wanted for as long as I can remember. CamStudio records the activity in a selected portion of your screen, and spits out an .avi. Its current version is from 2003, but, thanks to its open-sourceness, is still being developed. It gives you the option to use different recording codecs and to tweak their parameters, but the only way I was able to get results was with enormous files, approaching 1GB for 15 minutes of 320×240 video. Which is a pain in the ass, but it works.

Leave a Comment

That drunk Russian space pig thing

Pervye na Lune

Click the image for the full photo montage.

I first encountered this last year on WFMU’s blog, and despite being curious of its origins, the internet has trained me to accept content without context. Funny pictures, drunk pig, pass it on. Neither the WFMU post, nor the blog they got it from even ask where this came from. But who cares — find it, blog about it, Digg it, make a YTMND about it, a YouTube spinoff, and move on to the next meme.

But there’s something clearly artistic about these images. They’re too perfect. And they depict such a caricatured past that you suspect they may have been taken recently. And, as noted in the comments that I didn’t bother to read until today, they were.

First on the Moon poster

They’re stills from a 2005 Russian mockumentary called Pervye na lune, or First on the Moon, which actually looks good, its premise approaching what you might have expected if you speculated enough about the intent of those photos. From the film’s official site, as translated by Google:

You can argue long, the Americans were on the Moon or not, but there are facts that prove convincingly : Soviet scientists were able to run the first aircraft into space as early as March 1938. Information more than convincing, and at this time Russian cosmonauts ahead of the Americans …

It’s not on Netflix yet, but I hear it’s on Karagarga, the invite-only avant-garde film torrent tracker, which means it may soon make it to art torrents or gpod. There are also several copies on eBay, but I can’t be sure they have subtitles, or are even compatible with American DVD players.

Read more about it:

One Response