PDA

View Full Version : Editing each frame independently. Is it possible?


Susana
16th August 2006, 11:28
A have a video with variable letterbox, and I wanna use autocrop, resize and addborders (for a final 720x576 video frame size), but I need to do it frame by frame because of letterbox changes along the video (with autocrop producing different frame size in each frame). Is this possible, and how ?

Thank you.

Boulder
16th August 2006, 12:03
Richard Berg (IIRC) created a for-function which might be useful.

http://forum.doom9.org/showthread.php?t=106880

I have no idea how well it works in your case, it could be better to crop according to the largest letterbox area (or is the difference between them very big?).

Susana
16th August 2006, 12:49
thanks, i'll have a look.

Not very big, but the problem is image shifts between frames, maybe being due to irregular capture.
Exaggerating:

http://img209.imageshack.us/img209/5046/snap1lc1.gif

Didée
16th August 2006, 13:41
Get MVTools & MaskTools v2, and try s-th like

ref_frame = xxx # use position of this' frame borders throughout the clip

source = last
tall = source .BicubicResize(72,height,1,0) .mt_lut("x 18 < 16 235 ?")
tall_ref = tall .Trim(ref_frame,ref_frame) .Loop(framecount(source))
mixed1 = Interleave(tall_ref,tall)
mixed2 = Interleave(source,source)
vec = mixed1 .mvanalyse(truemotion=true,blksize=8,pel=2,isb=true,idx=98)

mixed2 .mvincrease(vec,10,1,idx=99) .SelectOdd()

Since it's a "drawn-on-paper" script only (can't try out now), chances are good that there's an error in the script. ;)

The idea is: leave borders black, make anything white that's brighter than a "black border", and then make a motion compensation of every single frame against one reference frame.

Susana
18th August 2006, 06:34
Well, I've been testing for-loop. Works well, but the max number of iterations is limited (around 1100) or the program crash (vdubmod), I don't know why so I've had to create a workaround (1000 frames in each iteration):

global clip_1=mpeg2source("C:\TEMP\D2VAVS\V01.D2V",idct=7)
global clip_2=clip_1.trim(0,-1)
global num=clip_1.framecount-1
global block="global clip_2=clip_2 + myfun(clip_1)"

#workaround (1000 iters each for-call)
(num>1000) ? for2("j=1","j<=1000","j=j+1",block) : For2("j=1","j<=num","j=j+1",block)
(num>2000) ? for2("j=1001", "j<=2000", "j=j+1", block) : ((num>1000) ? for2("j=1001", "j<=num", "j=j+1", block) : nop)
(num>3000) ? for2("j=2001", "j<=3000", "j=j+1", block) : ((num>2000) ? for2("j=2001", "j<=num", "j=j+1", block) : nop)
(num>4000) ? for2("j=3001", "j<=4000", "j=j+1", block) : ((num>3000) ? for2("j=3001", "j<=num", "j=j+1", block) : nop)
(num>5000) ? for2("j=4001", "j<=5000", "j=j+1", block) : ((num>4000) ? for2("j=4001", "j<=num", "j=j+1", block) : nop)
(num>6000) ? for2("j=5001", "j<=6000", "j=j+1", block) : ((num>5000) ? for2("j=5001", "j<=num", "j=j+1", block) : nop)
(num>7000) ? for2("j=6001", "j<=7000", "j=j+1", block) : ((num>6000) ? for2("j=6001", "j<=num", "j=j+1", block) : nop)
(num>8000) ? for2("j=7001", "j<=8000", "j=j+1", block) : ((num>7000) ? for2("j=7001", "j<=num", "j=j+1", block) : nop)
(num>9000) ? for2("j=8001", "j<=9000", "j=j+1", block) : ((num>8000) ? for2("j=8001", "j<=num", "j=j+1", block) : nop)
(num>10000) ? for2("j=9001", "j<=10000", "j=j+1", block) : ((num>9000) ? for2("j=9001", "j<=num", "j=j+1", block) : nop)
(num>11000) ? for2("j=10001", "j<=11000", "j=j+1", block) : ((num>10000) ? for2("j=10001", "j<=num", "j=j+1", block) : nop)
(num>12000) ? for2("j=11001", "j<=12000", "j=j+1", block) : ((num>11000) ? for2("j=11001", "j<=num", "j=j+1", block) : nop)
(num>13000) ? for2("j=12001", "j<=13000", "j=j+1", block) : ((num>12000) ? for2("j=12001", "j<=num", "j=j+1", block) : nop)
(num>14000) ? for2("j=13001", "j<=14000", "j=j+1", block) : ((num>13000) ? for2("j=13001", "j<=num", "j=j+1", block) : nop)
(num>15000) ? for2("j=14001", "j<=15000", "j=j+1", block) : ((num>14000) ? for2("j=14001", "j<=num", "j=j+1", block) : nop)
(num>16000) ? for2("j=15001", "j<=16000", "j=j+1", block) : ((num>15000) ? for2("j=15001", "j<=num", "j=j+1", block) : nop)
(num>17000) ? for2("j=16001", "j<=17000", "j=j+1", block) : ((num>16000) ? for2("j=16001", "j<=num", "j=j+1", block) : nop)
(num>18000) ? for2("j=17001", "j<=18000", "j=j+1", block) : ((num>17000) ? for2("j=17001", "j<=num", "j=j+1", block) : nop)
(num>19000) ? for2("j=18001", "j<=19000", "j=j+1", block) : ((num>18000) ? for2("j=18001", "j<=num", "j=j+1", block) : nop)
return clip_2


function For2(string init, string cond, string iter, string block)
{
For2Loop("global " + init, cond, "global " + iter, block)
}

function For2Loop(string init, string cond, string iter, string block)
{
Eval(init)
return Eval(cond)
\ ? Eval("""
Eval(block)
For2Loop(iter, cond, iter, block)
""")
\ : NOP
}

function myfun(clip clip_3)
{
#autocrop + 4/3 to 16/9 conversion
#only one frame each time
clip_3=autocrop(clip_1.trim(j,j),mode=0,threshold=25,wMultOf=2,hMultOf=2)
w=clip_3.width
h=clip_3.height
ar=w*(768/720)/h
wf=round(576*ar/(1024/720))
aux=(720-wf)/4
frac(aux)==0 ? eval("b=aux*2") : eval("b=aux*2-1")
frac(aux)==0 ? nop : eval("wf=wf+2")
clip_3=clip_3.LanczosResize(wf,576).AddBorders(b,0,b,0)
return clip_3
}


Anyway, this didn't solve my problem :o
I'll try Didée suggestion, thank you.