PDA

View Full Version : Scene by scene filtering


cjv
22nd October 2002, 02:19
Hi,
I am wondering if anyone knows a faster way to use Avisynth on a scene-by-scene filtering basis as described below. Let me explain. I'm beginning a long-term project and I'm currently manually going through VDub using the scene advance, and rating the scene on a scale of 1-5 (with 5 having the most action, and 1 being a close-up)
I then note the starting frame, and ending frame of the scene, and then go to my avisynth script like so:

LoadPlugin("C:\Program Files\Video\Plugins\mpeg2dec3.dll")
o=mpeg2source("C:\Video\Test\Test.d2v",lumoff=-2,idct=5).crop(8,58,704,360)
############################################
w=704
h=304

highAct="Convolution3D(0,8,16,8,16,3,0).BilinearResize(w,h)"
medAct= "Convolution3D(0,4,8,4,8,2.8,0).BicubicResize(w,h,0,0.5)"
lowAct= "Convolution3D(0,2,4,2,4,2.8,0).BicubicResize(w,h,0,0.6)"
noAct= "TemporalSoften(1,5,0).LanczosResize(w,h)"
closeup= "Unfilter(3,3).BicubicResize(w,h,0,0.6)"
############################################
s1=Eval("o.trim(0,83)." + highAct)
s2=Eval("o.trim(84,130)." + closeUp)
s3=Eval("o.trim(131,164)." + lowAct)
s4=Eval("o.trim(165,175)." + medAct)
s5=Eval("o.trim(176,380)." + highAct)
# ...etc...etc...etc :)
movie=s1 + s2 + s3 + s4 + s5 ### ..etc..etc..etc
return movie

Basically the VDub part is painful, yet unavoidable because I want to have total control...so I don't mind.
Any pointers on my script..or even a tool that might be better suited to this task? "Eval" seems kinda awkward..maybe there is something better? Yea, I know this is kinda crazy..any ideas/tips/critics appreciated.
Thanks,


cjv

SansGrip
22nd October 2002, 03:53
cjv: I'm beginning a long-term project

No kidding heheheh

or even a tool that might be better suited to this task?

Personally I would enter the frame data into, say, a comma-delimited text file then use Perl to convert it into an Avisynth script. If you don't know Perl, then, well, you could always hire me to write you a script -- or since it's a long-term project, learn it! :D :D

(By the way, when you're done this, you have to post the result somewhere so we can examine the result! It would be very interesting to encode the same material using maybe just a light C3D all the way through and see what difference all that effort makes... I hope for your sake it's a lot ;).)

-

P.S. I was kidding about paying me. If you're willing to do all that work and make the final encoding available, I'll write you a Perl script for free :)

cjv
22nd October 2002, 04:13
Hehe..a long-term project for sure! It's actually the Godfather collection..I just LOVE those films..and I feel the technology w/ XviD is advanced enough now to backup all parts at almost full D1 resolution (704x) using 2CD Simple Profile MPEG-4 (XviD-stable).
Unfortunately, I'm unhappy with a LOT of scenes in the original DVD remastering, and would like to improve them to my own satisfaction (eliminate grain..sharpen some soft scenes..deinterlace..etc..).

Anyways, yea I know Perl oh too well, and never thought of that (thanks SansGrip) But to install ActiveState Perl on Windows..I'm kinda skeptical :) Ha..I will just gen the script from Gentoo. (OT: Anyone tried that distro yet..it kicks ass!)

Thanks for the advice..wish me luck..I will post the finished .avs file (in about 3 months :))

cjv

SansGrip
22nd October 2002, 04:47
I feel the technology w/ XviD is advanced enough now to backup all parts at almost full D1 resolution (704x) using 2CD Simple Profile MPEG-4 (XviD-stable).

I'm kinda skeptical myself about getting a 3-hour movie on 2 CD's, but I'd be fascinated to hear how it goes.

Anyways, yea I know Perl oh too well, and never thought of that (thanks SansGrip) But to install ActiveState Perl on Windows..I'm kinda skeptical :)

ActiveState is awesome. I've been using it for a couple of years and it keeps getting better. Try it!

cjv
22nd October 2002, 20:39
Just reporting on some progress..it seems like I'm saving approx. 2-3megs/minute. (using XviD q2)

It's somewhat time-consuming, but I'm going through the scenes manually and heavily filtering crowds, heavy action sequences, very dark scenes, and in-the-distance shots...and also slightly sharpening very close dialog shots.

At 2.5megs/minute * 180 minutes = 450 megs saving! And withouth the sharpening it would be closer to (3.5*180)=600 megs!

Not something I'd want to do on every movie, but in this instance it appears to be worth it so far :)

cjv

SansGrip
22nd October 2002, 21:04
Just reporting on some progress..it seems like I'm saving approx. 2-3megs/minute. (using XviD q2)

That's pretty impressive. I can see how it might be worth it for sources that are very important to you, such as a wedding video or, er, the Godfather series ;).

Leuf
23rd October 2002, 00:58
Well, the 2 tasks you have are 1) break the movie down into scenes and choose the appropriate option 2) convert the scene/choice data to a working avisynth script.

For 1, what I would do is write a vdub filter with a scene detection algorithm (easy) that throws up a popup when it detects a scene change. Then all you have to do is load, hit play output, sit back and click. The filter then either outputs just a list of frame numbers and choices for later processing, or the complete avisynth script.

I've done something similar in the past for ivtc.



-Leuf

SansGrip
24th October 2002, 19:38
The filter then either outputs just a list of frame numbers and choices for later processing, or the complete avisynth script.

Very clever. I've made a note of this one :).

Xenoproctologist
25th October 2002, 02:18
A trick for these long sequences is to make the function as short as possible.


Syntax:

s(startframe,scenetype)

startframe: frame number of first frame in scene

scenetype: number identifying type of scene, where:
1 = closeup
2 = no action
3 = low action
4 = medium action
5 = high action

Video source must be set as global variable "source"
"Last" must be set at beginning of script, else script will fail.

This should be approximately analogous to the script you showed at the beginning of this thread:
LoadPlugin("C:\Program Files\Video\Plugins\mpeg2dec3.dll")
global source = mpeg2source("C:\Video\Test\Test.d2v",lumoff=-2,idct=5).crop(8,58,704,360)
last = source

function s(clip in, int "startframe", int "scenetype")
{
w=704
h=304

out = (scenetype==1) ?
\ source.Unfilter(3,3).BicubicResize(w,h,0,0.6)
\ : (scenetype==2) ?
\ source.TemporalSoften(1,5,0).LanczosResize(w,h)
\ :(scenetype==3) ?
\ source.Convolution3D(0,2,4,2,4,2.8,0).BicubicResize(w,h,0,0.6)
\ :(scenetype==4) ?
\ source.Convolution3D(0,4,8,4,8,2.8,0).BicubicResize(w,h,0,0.5)
\ :
\ source.Convolution3D(0,8,16,8,16,3,0).BilinearResize(w,h)

out = (startframe==0) ?
\ out
\ :
\ trim(in,0,startframe-1)+trim(out,startframe,0)

return out
}

s(0,5)
s(84,1)
s(131,3)
s(165,4)
s(176,5)

return last

cjv
26th October 2002, 04:20
@Xenoproctologist and all:

I appreciate everyone taking the time and the suggestions. I will definately use these ideas as a starting point. Only being able to work on this primarily Sundays, it will take a _long_ time to complete (so far I've completed approx. 13 mins!)..but I will post the final script in the future.
Thanks again,

cjv