Log in

View Full Version : AutoGordianKnot and Bitrate Calculate


ceearrashee
28th September 2007, 07:38
Hello all!
I makes many experiments, and get interest result...

if use this script for video:
QMotioFilter.avs

LoadPlugin("D:\Programs\AviSynth 2.5\plugins\mpeg2dec3.dll")
LoadPlugin("D:\Programs\AviSynth 2.5\plugins\decomb.dll")
LoadPlugin("D:\Programs\AviSynth 2.5\plugins\TemporalCleaner.dll")
LoadPlugin("D:\Programs\AviSynth 2.5\plugins\FluxSmooth25.dll")
LoadPlugin("D:\Programs\AviSynth 2.5\plugins\UnFilter.dll")

Import("d:\Install\MultiMedia\Converters\VirtualDubMod_1_5_10_1_All_inclusive\qmf.avs")

function Low_Motion_Filter(clip c)
{
c = TemporalCleaner(c, 5, 10)
c = LanczosResize(c, Width(c), Height(c))
return c
}

function Medium_Motion_Filter(clip c)
{
c = FluxSmooth(c, 7, 7)
c = BicubicResize(c, Width(c), Height(c), 0.00, 0.50)
return c
}

function High_Motion_Filter(clip c)
{
c = FluxSmooth(c, -1, 14)
c = UnFilter(c, -30, -30)
c = BilinearResize(c, Width(c), Height(c))
return c
}

DirectShowSource("D:\Video\Test.avi").KillAudio()
ConvertToYV12()
Telecide(0)

QMF()


QMF.avs

function ME()
{
global motion_level = (diff < threshold_lm) ? 0 : motion_level
global motion_level = (diff >= threshold_lm && diff <= threshold_hm) ? 1 : motion_level
global motion_level = (diff > threshold_hm) ? 2 : motion_level
}

function QMF(clip c, float "threshold_lm", float "threshold_hm", bool "debug")
{
threshold_lm = default(threshold_lm, 4.0)
threshold_hm = default(threshold_hm, 12.0)
global threshold_lm = threshold_lm
global threshold_hm = threshold_hm

debug = default(debug, false)

global motion_level = 0

global clip = c

width = Width(Low_Motion_Filter(c))
height = Height(Low_Motion_Filter(c))
global c_resized = PointResize(c, width, height)

c = ConditionalFilter(c, Low_Motion_Filter(c), c_resized, "motion_level", "=", "0") # [6a]
c = ConditionalFilter(c, Medium_Motion_Filter(c), c, "motion_level", "=", "1") # [6b]
c = ConditionalFilter(c, High_Motion_Filter(c), c, "motion_level", "=", "2") # [6c]

c = (debug == true) ? ScriptClip(c, "Debug()") : c

c = FrameEvaluate(c, "ME()")

c = FrameEvaluate(c, "global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")

// Set Output File
c = WriteFile(c,"e:\temp\Motion.log","motion_level")
c = Crop(c,0,0,4,4)
return c
}

function Debug(clip c)
{
c = Subtitle(c, "Quantified Motion Filter", x=20, y=30, font="lucida console", size=18, text_color=$FFFFFF)
c = Subtitle(c, "by HomiE FR (homie.fr@wanadoo.fr)", x=20, y=45, font="lucida console", size=14, text_color=$FFFFFF)

c = Subtitle(c, "motion estimation", x=20, y=85, font="lucida console", size=18, text_color=$FFFFFF)
c = Subtitle(c, "diff = "+string(diff), x=20,y=110, font="lucida console", size=16, text_color=$FFCCCC)

c = Subtitle(c, "quantified motion filter", x=20, y=135, font="lucida console", size=18, text_color=$FFFFFF)
c = (motion_level == 0) ? Subtitle(c, "scene type = low motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c
c = (motion_level == 1) ? Subtitle(c, "scene type = medium motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c
c = (motion_level == 2) ? Subtitle(c, "scene type = high motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c
return c
}



We will get log file with frame = motion quality, sum all id in log and division it on frame count.
We have number - it is bit per pixel value... may be, I doubt, but if I use it value in formula: width * height * (value) / 1024 = bit rate (hq).
It bit rate actually only for this video stream, and we can correctly calculate size, video stream quality.

And after all I’ll seen one interested property:
this value, at resolution 720 * 540 ≈ 0.3 bit/pixel;
but this value, enlarges to 0.5 bit/pixel, at resolution 320 * 240…

If anybody have interest result or ideas, I wait replies.