Log in

View Full Version : perl script(s) for analyzing xvid output


primitive
29th March 2002, 08:38
I decided I needed a tool to make sense of the xvid dbgv output I was seeing for the first pass stats. I wrote this perl script to help me.

What this script does is it first looks at the frame sizes of the quant:2 encode done in the first pass and finds the largest frame size of this quant:2 encode. Then it splits the range [0,$largest_frame] into $buckets regions and steps through an array containing all the frame sizes, incrementing the value in the appropriate region for that frame size. The output is a text file that you should be able to import into a spreadsheet program and make pretty pictures with.

If you want to use this script, here's how.

1) Open the script file and change the input file to the name of the file you saved your dbgv output to. This file should have in it the first-pass and the second-pass debug output from a single encoding session (i.e. one video file only).
2) I made this with the presumption you would be dumping it into a spreadsheet and making pretty graphs. Change $delimiter to the character your spreadsheet program uses to discriminate between multiple colums placed on a single row when importing a plain text file. AFAIK, Excel uses "," and OpenOffice uses "\t".
3) Change the value of $buckets. The smaller the value, the fuzzier the resolution of the output.

An analyzer for the second pass will be written tomorrow when I have time.

This is my first perl script ever. Hold me.

-p

*edit* Attach on this post failed, and I got bored so I finished my second perl script ever tonight as well. The .rar with them both is in the second post.

primitive
29th March 2002, 09:44
Ok, I got bored so I finished the second script anyway.

Download both the scripts here (http://people.vanderbilt.edu/~b.nuttall/analyze.rar).

A .gif showing what I can do with the output is attached. On the X axis is both the quant and the frame size so the Y axis would be the same scale in both cases. Since my quants went from 1 to 12 in the second pass, I went on and ran the first pass script with 12 buckets.

-p

*edit* Wow, I'm so tired I forgot to even mention what the second script /does/. It basically analyzes the quant distribution in the second pass stats in the file speficied and writes that distribution out to a file.

*edit* Until the picture attachment I added is approved, here's a link to it. Can't inline external pictures on this forum :(. http://people.vanderbilt.edu/~b.nuttall/output.gif

Neo Neko
29th March 2002, 20:59
Most interesting. I shall have to play with this.

primitive
31st March 2002, 03:28
@NN

I've been doing a little testing to see what I can do with these scripts. I think that the key to getting a great quality encode is to make it so the frame size curve and the quant curve look more or less the same. If you want to do this, please tweak the quantizers so that you don't get any quant=1 frames in the final output (the voice in my head tells me that quant=1 frames are huge).

Here's my theory: "cheap" frames are encoded with quants closest to 2. "Expensive" frames are encoded with higher quants. The frame sizes from all the frames encoded at quant=2 are given to us in the first-pass debug output. What we /should/ be able to do is use alt. curve compression to make the quant distribution look similar to the original framesize distribution.

I'm not at school to test what effects the altcc methods have on the properties of the quant curve of the output. However, I do have some predictions.

Agg=low, the quant curve will be flatter (higher numbers of high-quant and low-quant frames than normal); agg=high, curve will be steeper (fewer numbers of high-quant and low-quant frames than normal). Once you have tweaked the aggressiveness to match the first-pass curve, you can adjust the high% and low% to move the second-pass quant curve "hump" right and left. Increasing high% should move the hump to the right, and increasing low% past 100% should move the hump to the left (at the expense of making some nasty, nasty frames in high-bitrate scenes).

Also, since you have in your first pass stats the final size of the quant=2 first pass encode, you can accurately set the strength%.

I'll test out these ideas on Wednesday myself; I'd like someone else to take a look at these things this weekend, though ^^

-p