Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th November 2011, 16:19   #1  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
How to get DePan to fix Screen Shake?

I have a 720 x 480 interlaced MPEG2 video HERE which I've denoised. The original is HERE . The video moves up several pixels every few seconds which was probably caused by old VHS equipment. You can see the "USA" logo move up and down.

I found this code but it just gives wavey artefacts:
Code:
Mpeg2Source("E:\1\Screen Shake.d2v")
i = ConvertToYV12()
mdata = DePanEstimate(i)
DePanStabilize(i, data=mdata, initzoom=1.1)
I did a search on this forum but I couldn't find the answer. I looked at the DePan documentation but I couldn't understand it.

Could someone please suggest a filter and script to fix the screen shake. I'm not bothered if it's for DePan or not, just as long as it works. Thanks

Last edited by VideoFanatic; 15th November 2011 at 21:11.
VideoFanatic is offline   Reply With Quote
Old 15th November 2011, 19:54   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Didn't I just see this same clip in another post two days ago?
johnmeyer is offline   Reply With Quote
Old 15th November 2011, 19:59   #3  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
I wasn't very specific before so I deleted the post and rephrased it.
VideoFanatic is offline   Reply With Quote
Old 15th November 2011, 20:10   #4  |  Link
SSH4
Registered User
 
Join Date: Nov 2006
Posts: 90
1) deinterlace your source video!
2) clean it with denoisers, deblock or other
3) and only after this try DePanStabilize (or MVDepan+DePanStabilize)! Because calculation of motion vectors failed on so bad source.
SSH4 is offline   Reply With Quote
Old 15th November 2011, 21:43   #5  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
I tried the following:

Code:
Mpeg2Source("E:\1\Screen Shake.d2v", CPU=6)
DeGrainMedian(limitY=2, limitUV=3, mode=1, interlaced=true)
DeGrainMedian(limitY=2, limitUV=3, mode=1, interlaced=true)
AssumeTFF()
QTGMC()
mdata = DePanEstimate(dxmax=0)
DePanStabilize(last, data=mdata, initzoom=1.1)
SeparateFields()
SelectEvery(4,0,3)
Weave()
The top line deblocks and gets rid of most noise. The 2nd line gets rid of any remaining noise. The rest of the code fixes the screen shake. Please let me know what you think. HERE is the new video.
VideoFanatic is offline   Reply With Quote
Old 16th November 2011, 02:41   #6  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I threw together a crude script using bits and pieces I had lying around. This isn't a thing of beauty, but it should give you the idea.

Here's the video that results from this script:

Stabilized and Denoised

And here's the script. You can do the denoising first and then do the stabilization, as recommended above. I tried it both ways and thought I got better results doing the stabilization before the denoising. The depan stabilization works on large blocks so I think it may be somewhat immune to noise. Obviously any denoiser works better on compensated sources, and this approach compensates the source in two different ways before the denoising step.

I applied Depan at the field level rather than the frame level.

Code:
loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins\Film Restoration\Script_and_Plugins\mt_masktools.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins\Film Restoration\Script_and_Plugins\Depan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Film Restoration\Script_and_Plugins\DepanEstimate.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins\Film Restoration\Script_and_Plugins\removegrain.dll")

#STABILISING PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
maxstabH=20                                                         #maximum values for the stabiliser (in pixels) 20 is a good start value 
maxstabV=20
est_left=40  
est_top=40  
est_right=40  
est_bottom=40  
est_cont=1.6  

source=AVISource("E:\frameserver.avi").killaudio().AssumeTFF().converttoYV12()

stab_input=separatefields(source)

stab_reference= stab_input.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(threshold=80).greyscale().invert()
mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
stab=DePanStabilize(stab_input,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15).deflicker()

stabilized=weave(stab).Levels(16, 1, 235, 0, 255, coring=false)

denoised=MDegrain2i2(stabilized,8,0,0)

#stackvertical(source,denoised)
return denoised


#-------------------------------
function MDegrain2i2(clip source, int "blksize", int "overlap", int "dct")
{
Vshift=0 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
Hshift=0 # determine experimentally 
overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
dct=default(dct,0) # use dct=1 for clip with light flicker

fields=source.SeparateFields() # separate by fields

fixed_fields=MergeChroma(fields,crop(fields,Hshift,Vshift,0,0).addborders(0,0,Hshift,Vshift))

super = fixed_fields.MSuper(pel=2, sharp=1)
backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
backward_vec4 = super.MAnalyse(isb = true, delta = 4, blksize=blksize, overlap=overlap, dct=dct)
forward_vec4 = super.MAnalyse(isb = false, delta = 4, blksize=blksize, overlap=overlap, dct=dct)

MDegrain2(fixed_fields,super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400) #original setting

Weave()

}
johnmeyer is offline   Reply With Quote
Old 16th November 2011, 02:58   #7  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I downloaded your fixed video and it still looks to me like most of the jumps seen in the ropes around the ring are still as strong as the original. Take a look at frames 334 and 335 in your improved version compared to what I uploaded.
johnmeyer is offline   Reply With Quote
Old 16th November 2011, 04:13   #8  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
I had to change your source line to this as I need Mpeg2Source:

source=Mpeg2Source("E:\1\Screen Shake Denoised new.d2v").killaudio().AssumeTFF().converttoYV12()

I appreciate the time you took on your script but your script produces a terrible video! The whole picture moves giving a feeling of motion sickness and the borders move left and right.

Are you sure you watched the video I made with my script?
VideoFanatic is offline   Reply With Quote
Old 16th November 2011, 06:46   #9  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Quote:
Originally Posted by holygamer View Post
I had to change your source line to this as I need Mpeg2Source:

source=Mpeg2Source("E:\1\Screen Shake Denoised new.d2v").killaudio().AssumeTFF().converttoYV12()

I appreciate the time you took on your script but your script produces a terrible video! The whole picture moves giving a feeling of motion sickness and the borders move left and right.

Are you sure you watched the video I made with my script?
I did watch your video and I still have the same comments.

As to my attempt, I used too large a depan setting, and also didn't crop the edges. You will ALWAYS have to do a crop after using depan to reduce unwanted motion ("jumping" in your case) because depan does not include edge filling. You could use Deshaker, which does include this feature.

If you look at the ropes in my video, and ignore the edges (which as I stated above, can easily be fixed by using smaller motion compensation values, and then doing a small crop), the jumping has been eliminated.

Anyway, good luck with your project.

Last edited by johnmeyer; 16th November 2011 at 06:48. Reason: added one sentence to clarify -- edit made two minutes after post
johnmeyer is offline   Reply With Quote
Old 17th November 2011, 12:53   #10  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
Haven't downloaded it, but are the errors small enough for stab() to work?
2Bdecided is offline   Reply With Quote
Reply

Tags
bobbing, depan, screen shake, stabilization

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:10.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.