View Full Version : How to get DePan to fix Screen Shake?
VideoFanatic
15th November 2011, 16:19
I have a 720 x 480 interlaced MPEG2 video HERE (http://ge.tt/9uDR50A/v/1) which I've denoised. The original is HERE (http://game-soundtracks.com/Game%20Music/Screen%20Shake.mpg) . 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:
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
johnmeyer
15th November 2011, 19:54
Didn't I just see this same clip in another post two days ago?
VideoFanatic
15th November 2011, 19:59
I wasn't very specific before so I deleted the post and rephrased it.
SSH4
15th November 2011, 20:10
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.
VideoFanatic
15th November 2011, 21:43
I tried the following:
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 (http://ge.tt/8PT8F0A?c) is the new video.
johnmeyer
16th November 2011, 02:41
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 (http://dl.dropbox.com/u/1561578/fixed.avi)
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.
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
16th November 2011, 02:58
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.
VideoFanatic
16th November 2011, 04:13
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 (http://ge.tt/8PT8F0A?c) I made with my script?
johnmeyer
16th November 2011, 06:46
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 (http://ge.tt/8PT8F0A?c) 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.
2Bdecided
17th November 2011, 12:53
Haven't downloaded it, but are the errors small enough for stab() to work?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.