PDA

View Full Version : MPEG Compressibility DLL


MattO
18th December 2002, 13:47
Hi all,

This may be of interest to Sansgrip and those who use his filters.

Encoding using TMPGenc's CQ mode produces high quality video but the final file size is unpredictable. I know Sansgrip has create a predictor but this involves an extra initial encoding process to find out a clip's compressibility.

There are many all in one programs which control multiple programs to make encoding a one step process. I am trying to program one myself in Delphi. Some of these (like mine) make various calls to MPEG2DEC*.DLL to find out various information about a clip before encoding it, ie: clip length, frame rate etc. There have also been many diverse AVIsynth filters created here. This combination has led me to this idea:
Could a MPEG2COMP.DLL (or whatever ;) be created which excepts a call to it, much like MPEG2DEC*.DLL, to find out a clips compressibility?
What I was thinking was ...
A call is made to MPEG2COMP.DLL.
MPEG2COMP.DLL reads a given amount of frames from a clip.
It looks at its first frame (obviously not the first frame of the clip, which could be all black) and scans the pixel values to find black pixels, from this MPEG2COMP.DLL can work out whether the clip is 4:3, 1.85:1, 2.35:1 (I believe the AutoCrop filter may do something like this ? ).
MPEG2COMP.DLL then looks at the remaining pixels to get a total color value for the frame. It repeats this on a certain amount of frames throughout the clip to get an average color value for the whole clip. It could even look at groups of frames to take the clips motion into consideration.
MPEG2COMP.DLL returns this figure as the compressibility value, which will aid the setting of TMPGenc's CQ value.

The way I do it at the moment is, from within my Delphi app, I calculate the CBR value needed to encode the whole clip. I multiply this value by anything from 1.05 to 1.7 depending on its color and motion content, then use this value as TMPGenc's CQ Max bitrate. What I am hoping is to automate this process with a little more acurracy.

Please give your opinions

MattO