Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet
I had already done that
Good.

Where exactly are the leaks occurring?
Your chain looks like this:
AVI splitter > Lararith decoder > Avisynth frameserver > Avisynth plugins (MVTools2, SVPFlow, MaskTools2) > VD frameserver > Lagarith encoder
Memory leaks potentially may be in every element of chain. You can only control overall memory use by task manager against process VirtualDub. Look at this number and its growing while encoding your video with avisynth script.

Will these leaks someday get fixed?
First of all you need to find the element of chain with the error. In my practice I just use these 'buggy' tools but I know about their such features smile

how can one decide whether to use 0.2 or 0.1?
Only by view to result. Or I can explain how to debug the script to get current 'drop', 'Max_all' value for every frame. It will help to find threshold value: 0.1 or 0.2.

What's the difference
noise in the dropped frames and full frames matching are key differences. In battlefield clip every frame is slightly differ from previous as it encoded as individual frame with lossy encoder which decide to encode some new information (another mosquito noise, blocking, ringing for example) in every frame.

77 (edited by TCmullet 26-12-2014 04:58:38)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Can this be some other value, say, 0.15 or 0.175?  How would you describe what this is really governing?  If I didn't have the 0.1, I'd use the 0.2 and run the video through it.  There would be forward-drops that it failed to catch.  Then I'd run the new file through DoubleDrop to catch those.  But it would be really great if we could derive a simple procedure to determine the best number, hopefully avoiding doing test runs, etc..  (Sorry if I'm asking too much.)  If there's a qualitative way to describe what to look for in a video's characteristics, that would be good.  Maybe something like, "If the video was encoded from a clean source and with a lossless encoder, then use 0.1.  But if identical frames are highly non-identical strictly due to encoding artifacts, then use 0.2."  How's that for my guess?

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

I've had some results, but...

1.  I can only get about halfway through my files before VirtualDub blows up.  It always says it's in "Lagarith".   I was compensating by cutting  my Lagarith files into 2 pieces, but sometimes even that's not small enough.  Memory for Vdub starts out around 100mb+ and fluctuates upward to 500mb+ before it blows up.

2.  I've discovered that if I first covert my Lagarith file to Hufyuv, I can leave the video (2 hour program) in ONE piece, memory usage during my GameDropFix run reaches a whopping 1300mb+ but does NOT blow up.

So I guess it would seem that Lagarith is somehow defective.  I didn't want to suspect that for the longest time.  Maybe GameDropFix is testing it's limits.  Shall I proceed to contact the Lagarith author?  (By sending link to this page.)

Btw, I have 12GB of memory.  I'm wondering what it is that is leaving those "memory leak" puddles around.  After the run is finished, the memory stays tied up until I close the video file.  Can an AviSynth script have memory leaks?  If not, then could it be the DLL(s) involved?   (Mag79, you DID say that almost any software can leak memory.)  From what I understand memory leaks have to do with programs not properly releasing data items back to the operating system after they are done with them.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

3.  It seems that each time I run a file through GameDropFix, 9 frames are lost (the output file is 9 frames shorter than the input).

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet
Can an AviSynth script have memory leaks? 

Depends on avisynth version itself and on any plugin used.
For example Avisynth+ doesn't free cached video frames at exit.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

I'm using the AviSynth version that you all at SVP-team require.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Gamedrop-v4 was working pretty good for me (I think) back when I was using it.  Need to start using it again, but when I run it, the video window shows the image with text at the top saying:
"I don't know what "fix_clip" means ([ScriptClip], line 2)"

In the couple months since I was last using it, I HAVE made changes to my environment.  What is this telling me is wrong, please?  (My code is below.)

SetMemoryMax(1024)
global svp_scheduler=true
global threads=2
global svp_cache_fwd=threads+10

#LoadPlugin("C:\Program Files (x86)\SVP\plugins\svpflow1.dll")
#LoadPlugin("C:\Program Files (x86)\SVP\plugins\svpflow2.dll")

SetMTMode(3,threads)
AviSource("D:\Video-Work\myVideo.dups.avi").ConvertToYV12()
SetMTMode(2)

src=last
super_params_mini="{scale:{up:2},gpu:0}"
analyse_params_mini="{block:{w:8,h:8}}"
miniW = int(width/64)*32
miniW = (miniW<320) ? 320 : miniW
miniH = int(height/64)*32
miniH = (miniH<160) ? 160 : miniH
mini=BicubicResize(miniW,miniH).TemporalSoften(1, 1, 0, scenechange=1, mode=2)
super_mini=mini.SVSuper(super_params_mini)
vectors_mini=SVAnalyse(super_mini, analyse_params_mini)
vectors_Forward=SVConvert(vectors_mini, false)
HorizontalSpeed_luma=mini.MMask(vectors_Forward, kind=3).convertToRGB32().PointResize(miniW/8, miniH/8).PointResize(miniW/4, miniH/4).ConvertToYV12().mt_lut(y=2, u=128, v=128)
VerticalSpeed_luma=mini.MMask(vectors_Forward, kind=4).convertToRGB32().PointResize(miniW/8, miniH/8).PointResize(miniW/4, miniH/4).ConvertToYV12().mt_lut(y=2, u=128, v=128)

size=16
luma_lft=HorizontalSpeed_luma.crop(0,0,miniW/16,0).BicubicResize(size,size)
luma_rgh=HorizontalSpeed_luma.crop(miniW/16+miniW/8,0,0,0).BicubicResize(size,size)
luma_top=VerticalSpeed_luma.crop(0,0,0,miniH/16).BicubicResize(size,size)
luma_btm=VerticalSpeed_luma.crop(0,miniH/16+miniH/8,0,0).BicubicResize(size,size)
luma_drop=luma_lft.mt_lut(y=-1, u=128, v=128)

move_idx=5
y_idx=3
min_move=0.2
max_stop=0.5
drop_clip=luma_drop.ScriptClip("
    AvgLuma_lft=128-luma_lft.AverageLuma
    AvgLuma_rgh=128-luma_rgh.AverageLuma
    AvgLuma_lft_prev=128-(luma_lft.trim(1,1)+luma_lft).AverageLuma
    AvgLuma_rgh_prev=128-(luma_rgh.trim(1,1)+luma_rgh).AverageLuma
    AvgLuma_lft_next=128-luma_lft.trim(1,0).AverageLuma
    AvgLuma_rgh_next=128-luma_rgh.trim(1,0).AverageLuma

    AvgLuma_top=128-luma_top.AverageLuma
    AvgLuma_btm=128-luma_btm.AverageLuma
    AvgLuma_top_prev=128-(luma_top.trim(1,1)+luma_top).AverageLuma
    AvgLuma_btm_prev=128-(luma_btm.trim(1,1)+luma_btm).AverageLuma
    AvgLuma_top_next=128-luma_top.trim(1,0).AverageLuma
    AvgLuma_btm_next=128-luma_btm.trim(1,0).AverageLuma

    Max_lft=max(abs(AvgLuma_lft_prev),abs(AvgLuma_lft),abs(AvgLuma_lft_next))
    Max_rgh=max(abs(AvgLuma_rgh_prev),abs(AvgLuma_rgh),abs(AvgLuma_rgh_next))
    Max_top=max(abs(AvgLuma_top_prev),abs(AvgLuma_top),abs(AvgLuma_top_next))
    Max_btm=max(abs(AvgLuma_btm_prev),abs(AvgLuma_btm),abs(AvgLuma_btm_next))
    Max_all=max(Max_lft,Max_rgh,Max_top,Max_btm)
    
    MaxLuma=max(abs(AvgLuma_lft),abs(AvgLuma_rgh),abs(AvgLuma_top),abs(AvgLuma_btm))
    MaxLuma_prev=max(abs(AvgLuma_lft_prev),abs(AvgLuma_rgh_prev),abs(AvgLuma_top_prev),abs(AvgLuma_btm_prev))
    MaxLuma_next=max(abs(AvgLuma_lft_next),abs(AvgLuma_rgh_next),abs(AvgLuma_top_next),abs(AvgLuma_btm_next))
    dif=mini.YDifferenceFromPrevious
    dif_next=mini.trim(1,0).YDifferenceFromPrevious
    dif_prev=(mini.trim(1,1)+mini).YDifferenceFromPrevious
    
    GoodContrast = (max(mini.YPlaneMinMaxDifference,mini.trim(1,0).YPlaneMinMaxDifference)>20) ? 1 : 0

    drop = (MaxLuma<0.1 && MaxLuma*2<Max(MaxLuma_prev,MaxLuma_next) && dif*y_idx<max(dif_prev,dif_next)) ? 1 : 0

    drop_lft = (AvgLuma_lft_prev*AvgLuma_lft_next>0 && abs(AvgLuma_lft*move_idx)<Max_lft && abs(AvgLuma_lft)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 2 : 0
    drop_rgh = (AvgLuma_rgh_prev*AvgLuma_rgh_next>0 && abs(AvgLuma_rgh*move_idx)<Max_rgh && abs(AvgLuma_rgh)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 3 : 0
    drop_top = (AvgLuma_top_prev*AvgLuma_top_next>0 && abs(AvgLuma_top*move_idx)<Max_top && abs(AvgLuma_top)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 4 : 0
    drop_btm = (AvgLuma_btm_prev*AvgLuma_btm_next>0 && abs(AvgLuma_btm*move_idx)<Max_btm && abs(AvgLuma_btm)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 5 : 0
   
    drop = (drop==0 && MaxLuma<Max_stop && Max_lft==Max_all) ? drop_lft : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_rgh==Max_all) ? drop_rgh : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_top==Max_all) ? drop_top : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_btm==Max_all) ? drop_btm : drop
    drop_dif = (dif<0.4 && MaxLuma<min_move) ? 6 : 0
    drop = (drop==0 && drop_dif>0) ? drop_dif : drop
    drop = (drop>0 && Max_all<0.1) ? 0 : drop
    drop = (drop>0 && GoodContrast==0) ? 0 : drop

    luma=mini.AverageLuma
    luma_next=mini.trim(1,0).AverageLuma
    max_luma=max(luma,luma_next)

    drop = (drop>0 && max_luma<16.5) ? 0 : drop

    (drop>0) ? luma_drop : \
     (Max_lft==Max_all) ? luma_lft : \
      (Max_rgh==Max_all) ? luma_rgh : \
       (Max_top==Max_all) ? luma_top : luma_btm
")

fix_r50=luma_lft.mt_lut(y=-1, u=128, v=128)
fix_lr33=luma_lft.mt_lut(y=-2, u=128, v=128)
fix_l50=luma_lft.mt_lut(y=-3, u=128, v=128)
fix_r133=luma_lft.mt_lut(y=-4, u=128, v=128)
fix_r66=luma_lft.mt_lut(y=-5, u=128, v=128)

AvgDrop=127
MaxMulty=10
dblMulti=1.3
fix_clip=luma_drop.ScriptClip("
    drop=drop_clip.AverageLuma
    AvgLuma=abs(128-drop_clip.AverageLuma)
    AvgLuma_prev=abs(128-(drop_clip.trim(1,1)+drop_clip).AverageLuma)
    AvgLuma_prev_= (AvgLuma_prev==AvgDrop) ? 0 : AvgLuma_prev
    AvgLuma_prev2=abs(128-(drop_clip.trim(1,2)+drop_clip).AverageLuma)
    AvgLuma_next=abs(128-drop_clip.trim(1,0).AverageLuma)
    AvgLuma_next_= (AvgLuma_next==AvgDrop) ? 0 : AvgLuma_next
    AvgLuma_next2=abs(128-drop_clip.trim(2,0).AverageLuma)

    RightZero = (AvgLuma_prev_*MaxMulty<AvgLuma_next_) ? (AvgLuma_prev_>max_stop || AvgLuma_next_>max_stop) ? 1 : 0 : 0
    LeftZero = (AvgLuma_next_*MaxMulty<AvgLuma_prev_) ? (AvgLuma_prev_>max_stop || AvgLuma_next_>max_stop) ? 1 : 0 : 0

    drop = (AvgLuma==AvgDrop && AvgLuma_next==AvgDrop) ? -50 : 0
    drop = (AvgLuma==AvgDrop && AvgLuma_prev==AvgDrop) ? 50 : drop

    drop = (drop==0 && AvgLuma==AvgDrop && LeftZero==0 && RightZero==0) ? \
     AvgLuma_prev_>AvgLuma_next_*dblMulti ? -50 : \
      AvgLuma_prev_*dblMulti>=AvgLuma_next_ ? AvgLuma_next2==AvgDrop ? 50 : 33 : 50 : drop

    drop = (drop==0 && AvgLuma==AvgDrop && RightZero==0 && AvgLuma_next2==AvgDrop) ? -50 : drop
    drop = (drop==0 && AvgLuma==AvgDrop && LeftZero==0 && AvgLuma_prev2==AvgDrop) ? 66 : drop

    (drop==50) ? fix_r50 : \
     (drop==33) ? fix_lr33 : \
      (drop==-50) ? fix_l50 : \
       (drop==133) ? fix_r133 : \
        (drop==66) ? fix_r66 : drop_clip
")

r50=1
lr33=2
l50=3
r133=4
r66=5

super_params="{scale:{up:2},gpu:0}"
analyse_params="{main:{search:{coarse:{distance:4,bad:{sad:2000}},type:2,distance:4},penalty:{lambda:1,pglobal:10000}},refine:[{thsad:65000}]}"
smoothfps_params="{rate:{num:12,den:1},algo:13,scene:{blend:true}}"

super=SVSuper(super_params)
vectors=SVAnalyse(super, analyse_params)
fix_all = SVSmoothFps(super, vectors, smoothfps_params, mt=threads, url="www.svp-team.com")
#----------------
#These are for visual debugging (the "Subtitle" clauses)
#fix50 = fix_all.SelectEvery(12,6).Subtitle("fix50", align=3, size=12)
#fix33 = fix_all.SelectEvery(12,4).Subtitle("fix33", align=3, size=12)
#fix66 = fix_all.SelectEvery(12,8).Subtitle("-fix33", align=3, size=12)
#fix66p = fix_all.SelectEvery(12,8).Subtitle("fix66", align=3, size=12)
#fix75 = fix_all.SelectEvery(12,9).Subtitle("-fix25", align=3, size=12)
#fix50n = fix_all.SelectEvery(12,6).Subtitle("-fix50", align=3, size=12)
#fix133 = fix_all.SelectEvery(12,4).Subtitle("fix133", align=3, size=12)
#fix125 = fix_all.SelectEvery(12,3).Subtitle("fix125", align=3, size=12)
#-----------------
fix50 = fix_all.SelectEvery(12,6)
fix33 = fix_all.SelectEvery(12,4)
fix66 = fix_all.SelectEvery(12,8)
fix66p = fix_all.SelectEvery(12,8)
fix75 = fix_all.SelectEvery(12,9)
fix50n = fix_all.SelectEvery(12,6)
fix133 = fix_all.SelectEvery(12,4)
fix125 = fix_all.SelectEvery(12,3)

ScriptClip("
    AvgFix=fix_clip.AverageLuma
    AvgFix_next=fix_clip.trim(1,0).AverageLuma
    AvgFix_next2=fix_clip.trim(2,0).AverageLuma
    AvgFix_next3=fix_clip.trim(3,0).AverageLuma
    AvgFix_prev=(fix_clip.trim(1,1)+fix_clip).AverageLuma

    (AvgFix==r50) \
      ? (AvgFix_next2==lr33 || AvgFix_next2==l50) ? fix33 : fix50 : \
    (AvgFix==lr33) ? fix33 : \
    (AvgFix_next==lr33) \
     ? (AvgFix_prev==r66) ? fix75.trim(1,1)+fix75 : fix66.trim(1,1)+fix66 : \
    (AvgFix_next==l50) \
      ? (AvgFix_prev==lr33 || AvgFix_prev==r50) ? fix66.trim(1,1)+fix66 \
      : (AvgFix_prev==r66) ? fix75.trim(1,1)+fix75 : fix50n.trim(1,1)+fix50n : \
    (AvgFix==r66) \
      ? (AvgFix_next2==lr33 || AvgFix_next2==l50) ? fix50 : fix66p : \
    (AvgFix_next==r66) \
      ? (AvgFix_next3==lr33 || AvgFix_next3==l50) ? fix125.trim(1,0) : fix133.trim(1,0) : \
    last
")

trim(0,framecount-10)

Distributor()

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet
It is Avisynth 2.6 issue. To make script compatible to avisynth 2.6 you need to add line

SetMTMode(5)

before lines

ScriptClip(" 
AvgFix=fix_clip.AverageLuma


It is solution by Howler. Try it.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Made no difference.  Double checked that I had saved the avs file and totally restarted Vdub.

When I added the line, I copy pasted from your post above (no re-typing).

85 (edited by James D 05-03-2015 05:56:15)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

That solution is useless performance wise, at least as I tested but it should work, provide full script. You get better performance without even enabling MT Mode for whole script than enabling it for 1 part and disabling it (practically what MT 5 does) for 2nd part.
But perhaps it gives another result with different type of video or bigger amount of drops. So I recommend to delete all SetMTMode lines.
Older Avisynth 2.5.8 is also slow even if using MT script with 50-60% fluctuating processor load so I'm not even sure if it actually uses multiple cores for 2nd part of script. I believe either script or Avisynth.dll should be changed for usingall CPU cores at max.
Just my observations because I spent hours on this single problem.
From Avisynth MT Wiki:   * Mode 5 is slowest (slower than not using SetMTMode)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

James, if you were suggesting that I "provide the full script", I did, except that after adding the one new line I did not supply the script again.

Will try your idea of removing all SetMTMode lines.  (But this WAS working weeks ago.  Maybe since then was when I made the change from AviSynth 2.5.8.0 to 2.6.0.5, which I needed to do for other reasons.)

87 (edited by James D 05-03-2015 06:06:47)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet
I did, except that after adding the one new line I did not supply the script again.
Which is exactly why I asked, to see where exactly you put that line because I'm sure that copy-pasting doesn't change copied text aka pastes text with mistakes..

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Here's the immediate context showing where I inserted the line:

fix133 = fix_all.SelectEvery(12,4)
fix125 = fix_all.SelectEvery(12,3)

SetMTMode(5)
ScriptClip("
    AvgFix=fix_clip.AverageLuma
    AvgFix_next=fix_clip.trim(1,0).AverageLuma
    AvgFix_next2=fix_clip.trim(2,0).AverageLuma
    AvgFix_next3=fix_clip.trim(3,0).AverageLuma
    AvgFix_prev=(fix_clip.trim(1,1)+fix_clip).AverageLuma

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet
Yeah, I can reproduce your error if I put (distributor) at the end (or anywhere after SetMTMode (5)). Just delete all SetMTModes, set global threads to 1 and live happy.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

James D wrote:

Just delete all SetMTModes, set global threads to 1 and live happy.

Happy to try.  Sad that it failed with "Softwire: caught an access violation at 0x022c4d20(code+332), attempting to read from 0x00000000 ([ScriptClip], line 2)

I guess it's time for my entire and exact script:

SetMemoryMax(1024)
global svp_scheduler=true
global threads=1
global svp_cache_fwd=threads+10

#LoadPlugin("C:\Program Files (x86)\SVP\plugins\svpflow1.dll")
#LoadPlugin("C:\Program Files (x86)\SVP\plugins\svpflow2.dll")

#SetMTMode(3,threads)
AviSource("D:\Video-Work\2014-NCAA-wv\2014-11-07.wv.KsSt-v-TX.x264v-q0.ac3-320.dups.avi").ConvertToYV12()
#SetMTMode(2)

src=last
super_params_mini="{scale:{up:2},gpu:0}"
analyse_params_mini="{block:{w:8,h:8}}"
miniW = int(width/64)*32
miniW = (miniW<320) ? 320 : miniW
miniH = int(height/64)*32
miniH = (miniH<160) ? 160 : miniH
mini=BicubicResize(miniW,miniH).TemporalSoften(1, 1, 0, scenechange=1, mode=2)
super_mini=mini.SVSuper(super_params_mini)
vectors_mini=SVAnalyse(super_mini, analyse_params_mini)
vectors_Forward=SVConvert(vectors_mini, false)
HorizontalSpeed_luma=mini.MMask(vectors_Forward, kind=3).convertToRGB32().PointResize(miniW/8, miniH/8).PointResize(miniW/4, miniH/4).ConvertToYV12().mt_lut(y=2, u=128, v=128)
VerticalSpeed_luma=mini.MMask(vectors_Forward, kind=4).convertToRGB32().PointResize(miniW/8, miniH/8).PointResize(miniW/4, miniH/4).ConvertToYV12().mt_lut(y=2, u=128, v=128)

size=16
luma_lft=HorizontalSpeed_luma.crop(0,0,miniW/16,0).BicubicResize(size,size)
luma_rgh=HorizontalSpeed_luma.crop(miniW/16+miniW/8,0,0,0).BicubicResize(size,size)
luma_top=VerticalSpeed_luma.crop(0,0,0,miniH/16).BicubicResize(size,size)
luma_btm=VerticalSpeed_luma.crop(0,miniH/16+miniH/8,0,0).BicubicResize(size,size)
luma_drop=luma_lft.mt_lut(y=-1, u=128, v=128)

move_idx=5
y_idx=3
min_move=0.2
max_stop=0.5
drop_clip=luma_drop.ScriptClip("
    AvgLuma_lft=128-luma_lft.AverageLuma
    AvgLuma_rgh=128-luma_rgh.AverageLuma
    AvgLuma_lft_prev=128-(luma_lft.trim(1,1)+luma_lft).AverageLuma
    AvgLuma_rgh_prev=128-(luma_rgh.trim(1,1)+luma_rgh).AverageLuma
    AvgLuma_lft_next=128-luma_lft.trim(1,0).AverageLuma
    AvgLuma_rgh_next=128-luma_rgh.trim(1,0).AverageLuma

    AvgLuma_top=128-luma_top.AverageLuma
    AvgLuma_btm=128-luma_btm.AverageLuma
    AvgLuma_top_prev=128-(luma_top.trim(1,1)+luma_top).AverageLuma
    AvgLuma_btm_prev=128-(luma_btm.trim(1,1)+luma_btm).AverageLuma
    AvgLuma_top_next=128-luma_top.trim(1,0).AverageLuma
    AvgLuma_btm_next=128-luma_btm.trim(1,0).AverageLuma

    Max_lft=max(abs(AvgLuma_lft_prev),abs(AvgLuma_lft),abs(AvgLuma_lft_next))
    Max_rgh=max(abs(AvgLuma_rgh_prev),abs(AvgLuma_rgh),abs(AvgLuma_rgh_next))
    Max_top=max(abs(AvgLuma_top_prev),abs(AvgLuma_top),abs(AvgLuma_top_next))
    Max_btm=max(abs(AvgLuma_btm_prev),abs(AvgLuma_btm),abs(AvgLuma_btm_next))
    Max_all=max(Max_lft,Max_rgh,Max_top,Max_btm)
    
    MaxLuma=max(abs(AvgLuma_lft),abs(AvgLuma_rgh),abs(AvgLuma_top),abs(AvgLuma_btm))
    MaxLuma_prev=max(abs(AvgLuma_lft_prev),abs(AvgLuma_rgh_prev),abs(AvgLuma_top_prev),abs(AvgLuma_btm_prev))
    MaxLuma_next=max(abs(AvgLuma_lft_next),abs(AvgLuma_rgh_next),abs(AvgLuma_top_next),abs(AvgLuma_btm_next))
    dif=mini.YDifferenceFromPrevious
    dif_next=mini.trim(1,0).YDifferenceFromPrevious
    dif_prev=(mini.trim(1,1)+mini).YDifferenceFromPrevious
    
    GoodContrast = (max(mini.YPlaneMinMaxDifference,mini.trim(1,0).YPlaneMinMaxDifference)>20) ? 1 : 0

    drop = (MaxLuma<0.1 && MaxLuma*2<Max(MaxLuma_prev,MaxLuma_next) && dif*y_idx<max(dif_prev,dif_next)) ? 1 : 0

    drop_lft = (AvgLuma_lft_prev*AvgLuma_lft_next>0 && abs(AvgLuma_lft*move_idx)<Max_lft && abs(AvgLuma_lft)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 2 : 0
    drop_rgh = (AvgLuma_rgh_prev*AvgLuma_rgh_next>0 && abs(AvgLuma_rgh*move_idx)<Max_rgh && abs(AvgLuma_rgh)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 3 : 0
    drop_top = (AvgLuma_top_prev*AvgLuma_top_next>0 && abs(AvgLuma_top*move_idx)<Max_top && abs(AvgLuma_top)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 4 : 0
    drop_btm = (AvgLuma_btm_prev*AvgLuma_btm_next>0 && abs(AvgLuma_btm*move_idx)<Max_btm && abs(AvgLuma_btm)<=min_move && dif*y_idx<max(dif_prev,dif_next)) ? 5 : 0
   
    drop = (drop==0 && MaxLuma<Max_stop && Max_lft==Max_all) ? drop_lft : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_rgh==Max_all) ? drop_rgh : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_top==Max_all) ? drop_top : drop
    drop = (drop==0 && MaxLuma<Max_stop && Max_btm==Max_all) ? drop_btm : drop
    drop_dif = (dif<0.4 && MaxLuma<min_move) ? 6 : 0
    drop = (drop==0 && drop_dif>0) ? drop_dif : drop
    drop = (drop>0 && Max_all<0.1) ? 0 : drop
    drop = (drop>0 && GoodContrast==0) ? 0 : drop

    luma=mini.AverageLuma
    luma_next=mini.trim(1,0).AverageLuma
    max_luma=max(luma,luma_next)

    drop = (drop>0 && max_luma<16.5) ? 0 : drop

    (drop>0) ? luma_drop : \
     (Max_lft==Max_all) ? luma_lft : \
      (Max_rgh==Max_all) ? luma_rgh : \
       (Max_top==Max_all) ? luma_top : luma_btm
")

fix_r50=luma_lft.mt_lut(y=-1, u=128, v=128)
fix_lr33=luma_lft.mt_lut(y=-2, u=128, v=128)
fix_l50=luma_lft.mt_lut(y=-3, u=128, v=128)
fix_r133=luma_lft.mt_lut(y=-4, u=128, v=128)
fix_r66=luma_lft.mt_lut(y=-5, u=128, v=128)

AvgDrop=127
MaxMulty=10
dblMulti=1.3
fix_clip=luma_drop.ScriptClip("
    drop=drop_clip.AverageLuma
    AvgLuma=abs(128-drop_clip.AverageLuma)
    AvgLuma_prev=abs(128-(drop_clip.trim(1,1)+drop_clip).AverageLuma)
    AvgLuma_prev_= (AvgLuma_prev==AvgDrop) ? 0 : AvgLuma_prev
    AvgLuma_prev2=abs(128-(drop_clip.trim(1,2)+drop_clip).AverageLuma)
    AvgLuma_next=abs(128-drop_clip.trim(1,0).AverageLuma)
    AvgLuma_next_= (AvgLuma_next==AvgDrop) ? 0 : AvgLuma_next
    AvgLuma_next2=abs(128-drop_clip.trim(2,0).AverageLuma)

    RightZero = (AvgLuma_prev_*MaxMulty<AvgLuma_next_) ? (AvgLuma_prev_>max_stop || AvgLuma_next_>max_stop) ? 1 : 0 : 0
    LeftZero = (AvgLuma_next_*MaxMulty<AvgLuma_prev_) ? (AvgLuma_prev_>max_stop || AvgLuma_next_>max_stop) ? 1 : 0 : 0

    drop = (AvgLuma==AvgDrop && AvgLuma_next==AvgDrop) ? -50 : 0
    drop = (AvgLuma==AvgDrop && AvgLuma_prev==AvgDrop) ? 50 : drop

    drop = (drop==0 && AvgLuma==AvgDrop && LeftZero==0 && RightZero==0) ? \
     AvgLuma_prev_>AvgLuma_next_*dblMulti ? -50 : \
      AvgLuma_prev_*dblMulti>=AvgLuma_next_ ? AvgLuma_next2==AvgDrop ? 50 : 33 : 50 : drop

    drop = (drop==0 && AvgLuma==AvgDrop && RightZero==0 && AvgLuma_next2==AvgDrop) ? -50 : drop
    drop = (drop==0 && AvgLuma==AvgDrop && LeftZero==0 && AvgLuma_prev2==AvgDrop) ? 66 : drop

    (drop==50) ? fix_r50 : \
     (drop==33) ? fix_lr33 : \
      (drop==-50) ? fix_l50 : \
       (drop==133) ? fix_r133 : \
        (drop==66) ? fix_r66 : drop_clip
")

r50=1
lr33=2
l50=3
r133=4
r66=5

super_params="{scale:{up:2},gpu:0}"
analyse_params="{main:{search:{coarse:{distance:4,bad:{sad:2000}},type:2,distance:4},penalty:{lambda:1,pglobal:10000}},refine:[{thsad:65000}]}"
smoothfps_params="{rate:{num:12,den:1},algo:13,scene:{blend:true}}"

super=SVSuper(super_params)
vectors=SVAnalyse(super, analyse_params)
fix_all = SVSmoothFps(super, vectors, smoothfps_params, mt=threads, url="www.svp-team.com")
#----------------
#These are for visual debugging (the "Subtitle" clauses)
#fix50 = fix_all.SelectEvery(12,6).Subtitle("fix50", align=3, size=12)
#fix33 = fix_all.SelectEvery(12,4).Subtitle("fix33", align=3, size=12)
#fix66 = fix_all.SelectEvery(12,8).Subtitle("-fix33", align=3, size=12)
#fix66p = fix_all.SelectEvery(12,8).Subtitle("fix66", align=3, size=12)
#fix75 = fix_all.SelectEvery(12,9).Subtitle("-fix25", align=3, size=12)
#fix50n = fix_all.SelectEvery(12,6).Subtitle("-fix50", align=3, size=12)
#fix133 = fix_all.SelectEvery(12,4).Subtitle("fix133", align=3, size=12)
#fix125 = fix_all.SelectEvery(12,3).Subtitle("fix125", align=3, size=12)
#-----------------
fix50 = fix_all.SelectEvery(12,6)
fix33 = fix_all.SelectEvery(12,4)
fix66 = fix_all.SelectEvery(12,8)
fix66p = fix_all.SelectEvery(12,8)
fix75 = fix_all.SelectEvery(12,9)
fix50n = fix_all.SelectEvery(12,6)
fix133 = fix_all.SelectEvery(12,4)
fix125 = fix_all.SelectEvery(12,3)

#SetMTMode(5)
ScriptClip("
    AvgFix=fix_clip.AverageLuma
    AvgFix_next=fix_clip.trim(1,0).AverageLuma
    AvgFix_next2=fix_clip.trim(2,0).AverageLuma
    AvgFix_next3=fix_clip.trim(3,0).AverageLuma
    AvgFix_prev=(fix_clip.trim(1,1)+fix_clip).AverageLuma

    (AvgFix==r50) \
      ? (AvgFix_next2==lr33 || AvgFix_next2==l50) ? fix33 : fix50 : \
    (AvgFix==lr33) ? fix33 : \
    (AvgFix_next==lr33) \
     ? (AvgFix_prev==r66) ? fix75.trim(1,1)+fix75 : fix66.trim(1,1)+fix66 : \
    (AvgFix_next==l50) \
      ? (AvgFix_prev==lr33 || AvgFix_prev==r50) ? fix66.trim(1,1)+fix66 \
      : (AvgFix_prev==r66) ? fix75.trim(1,1)+fix75 : fix50n.trim(1,1)+fix50n : \
    (AvgFix==r66) \
      ? (AvgFix_next2==lr33 || AvgFix_next2==l50) ? fix50 : fix66p : \
    (AvgFix_next==r66) \
      ? (AvgFix_next3==lr33 || AvgFix_next3==l50) ? fix125.trim(1,0) : fix133.trim(1,0) : \
    last
")

#trim(0,framecount-10)

Distributor()

Just had an additional thought.  Maybe I should upgrade the two svp dlls to the new ones that SubJunk provided with the new 2.8.0 Interframe.  Your thoughts?

91 (edited by James D 05-03-2015 07:16:05)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

I believe you should delete Distributor too roll And Setmemorymax is not needed in ST mode I guess.
I use latest svp dlls from latest svp update archieve. I thought they didn't change after Interframe 2.7.0 but never checked.
P.S. I prefer Subtle size 120 instead of 12 for visual debugging (the "Subtitle" clauses).
P.P.S. It wasn't too hard to give ful script, was it?:) tongue


I tried to check speed with AVS 2.5.8 again but Xvid4PSP crashes hard every time. Sad.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

James D wrote:

I believe you should delete Distributor too roll And Setmemorymax is not needed in ST mode I guess.

I'm happy to try your suggestions, but I'm running kinda blind as I don't know most of these items.  Take "distributor".  Have searched quite awhile and cannot find any clear documentation as to what it does.  That's okay, as I'll proceed with you (or you all) as my guide.  I get impression it has something to do with making something multithreaded.  Heck, I'll be glad to get this going with 1 thread, as my tasks (video files) needing this are not many.

I use latest svp dlls from latest svp update archieve. I thought they didn't change after Interframe 2.7.0 but never checked.

They must have changed, as InterFrame 2.8.0 just came out today (by coincidence) and uses newer svp dlls.

P.S. I prefer Subtle size 120 instead of 12 for visual debugging (the "Subtitle" clauses).

Yes, my eyes are weak, too.  (Good idea.)  But as you can see, I comment all that out anyway.

P.P.S. It wasn't too hard to give full script, was it?:) tongue

But I hate (translate that, "feel a little guilty") cluttering up so much vertical space when only a snippet of context will do.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

I got it working!

Musta been the taking out of "Distributor" and "Setmemorymax".

But then I got bold and replaced the dlls (svpflow1.dll and svpflow2.dll) with the new ones via the InterFrame 2.8.0 dependencies folder (figuring it might run even better), and now it bombs:

Avisynth open failure:
SVConvert: invalid vectors stream

Then it says it's from line 23, which is:

vectors_Forward=SVConvert(vectors_mini, false)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet

SVConvert: invalid vectors stream

Thank you. We need to check it. Perhaps it is true. Then wait for the fix.

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

I was a programmer for years before I became obsolete.  I know the value of user feedback.  Even now, I'm wrestling with php problems at my website via user feedback even though I thought I had EVERY possible scenario tested!

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

TCmullet

try this

[deleted]

97 (edited by James D 06-03-2015 10:16:19)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Chainik
try this

No success. This time shows something about access violation 0x00028383 in line vectors_Forward=SVConvert(vectors_mini, false)
For exact error download file.
Added: LOL, after this access violation I revert to any script like default script for instanse and get some bass.dll error:) after switching to another script it has no error.

video = FFmpegSource2("E:\source.mp4", rffmode=0, threads=1, cachefile="T:\Temp\source.mp4.ffindex").AssumeFPS(25.000)
audio = bassAudioSource("T:\Temp\0000_0.aac")
AudioDub(video, audio)

Furthermore I found disturbing but with both svpflow1.dll files (2.7 and 2.7.0.1). Do you remember I told about stuttering on some kind of videos where there was 1 frame, then a frame couple frames before and then again good frame (I created topic here with video in the past).
Well with these files I have that stuttering on Potplayer, Обработка видео - не обрабатывать even on those videos where everything was fine, on EVERY video now.

Post's attachments

Access violation at 0x00028383.png, 17.52 kb, 729 x 51
Access violation at 0x00028383.png 17.52 kb, 586 downloads since 2015-03-06 

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

this one definitely should work
this time I tested it  big_smile

Post's attachments

svpflow1.dll 348.5 kb, 526 downloads since 2015-03-06 

99 (edited by James D 06-03-2015 11:59:35)

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

Yeah, no errors while encoding.

But the frame-mixing bug with potplayer is still here on all videos like here. http://youtu.be/oWtv9I0RIQQ
If you don't plan on troubleshooting it, can I use newer svpflow2.dll with older svpflow1.dll?

Re: Fixing dropped frames in action cam footage? (for stereoscopic 3D)

James D
If you don't plan on troubleshooting it

do you really think it's relevant to the topic?

can I use newer svpflow2.dll with older svpflow1.dll?

no