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 8th December 2008, 22:55   #1  |  Link
Dada_
Registered User
 
Join Date: Jun 2008
Posts: 8
Stabilizing image: how?

Hey there, I'm working on translating an anime in Dutch. I also want to fix up the image since it's rather poor and from VHS (and even the DVDs are of that poor quality). Here's a short sample clip: http://tmp.thingmajig.org/output.mkv (3,832 KB)

The clip is made with the following script:
Code:
v = DGDecode_MPEG2Source("c:\avisynth\input_mpg.d2v")
a = DirectShowSource("c:\avisynth\input_mpg Tc0 L2 2ch 44.1 224 DELAY 0ms.mpa")

c = AudioDub(v, a)

c

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\Deen.dll")
deen("a3d",1,10,8)
What I want to do now is stabilize the image. As you can tell from the example I posted, the image has a very subtle shake.

Is it even possible to get this kind of shaking out, or should I just live with it?

I tried using GenMotion:
Code:
v = DGDecode_MPEG2Source("c:\avisynth\input_mpg.d2v")
a = DirectShowSource("c:\avisynth\input_mpg Tc0 L2 2ch 44.1 224 DELAY 0ms.mpa")

c = AudioDub(v, a)

c

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\avisynth_c.dll")
LoadVirtualdubPlugin("C:\Program Files\AviSynth 2.5\plugins\Deshaker.vdf", "Deshake")
loadCPlugin("C:\avisynth\Genmotion.dll")


converttoYV12(c)
f=GenMotion(c, filename="C:\avisynth\ajkdeshaker.log", delta=1)
b=GenMotion(c, filename="C:\avisynth\ajkdeshaker.log", delta=-1)
interleave(f,c,b)
selectevery(3,1)
converttoYUY2(c)
But it caused the error GenMotion: Cannot open input file ! (C:\avisynth\ajk_shake.avs, line 14)

I don't really know how to fix this. Should I be using this plugin or is there a better one that I could try?

Any help is appreciated!
Dada_ is offline   Reply With Quote
Old 9th December 2008, 08:33   #2  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Deshaker is a two pass filter! Your script tries to read the deshaker log file. This log file should be created in the first pass from deshaker. I do not know how to configure Avisynth for this, but it should be possible.

Anyhow... Use DepanStabilize() instead.

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 9th December 2008, 08:56   #3  |  Link
PeaceAnt
also known as GrassHoppeR
 
Join Date: Mar 2006
Location: Poland
Posts: 30
for first pass i use:
Code:
loadvirtualdubplugin("D:\Program Files\VirtualDubMod\plugins\Deshaker.vdf","Deshaker")
Deshaker("11|1|30|4|1.33333|7|1|0|640|480|1|2|1|400|400|400|1500|4|0|1|2|5|40|300|4|"\
+a+".log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1|15|1000|1")
this will analyze motion and save log file.
and then 2nd pass:
Code:
loadvirtualdubplugin("D:\Program Files\VirtualDubMod\plugins\Deshaker.vdf","Deshaker")
Deshaker("11|2|30|4|1.33333|7|1|0|640|480|1|2|1|400|400|400|1500|4|1|0|2|5|40|300|4|"\
+a+".log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|2|2|1|1|0|0|30|30|0|0|0|0|1|0|0|10|1|15|1000|1")
deshaker parameters you can copy directly from saved processing settings of virtual dub (*.vcf).

here's result (click "stab unstab.avi"):
http://wyslijplik.pl/download.php?sid=Wt93E7xb


more informations (in polish) on http://forum.filmowiec.pl/viewtopic.php?t=13226

pozdrawiam
PeaceAnt is offline   Reply With Quote
Old 9th December 2008, 21:57   #4  |  Link
Dada_
Registered User
 
Join Date: Jun 2008
Posts: 8
Thanks, PeaceAnt! I've given it a try, but I can't seem to get (the first pass, at least) to work. It "works" (as in, there's no error) when I view the .avs, but when I try to render it, I get a common fatal error:
Code:
avis [error]: unsupported input format (DIB )
x264 [error]: could not open input file 'ajk_pass1.avs'
Here are my scripts.
First pass:
Code:
v = DGDecode_MPEG2Source("c:\avisynth\input_mpg.d2v")
a = DirectShowSource("c:\avisynth\input_mpg Tc0 L2 2ch 44.1 224 DELAY 0ms.mpa")

c = AudioDub(v, a)

c

ConvertToRGB32()

log_name = "ajk_shake"

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\avisynth_c.dll")
LoadVirtualdubPlugin("C:\Program Files\AviSynth 2.5\plugins\Deshaker.vdf", "Deshaker")
Deshaker("11|1|30|4|1.33333|7|1|0|640|480|1|2|1|400|400|400|1500|4|0|1|2|5|40|300|4|"+log_name+".log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1|15|1000|1")
Second pass:
Code:
v = DGDecode_MPEG2Source("c:\avisynth\input_mpg.d2v")
a = DirectShowSource("c:\avisynth\input_mpg Tc0 L2 2ch 44.1 224 DELAY 0ms.mpa")

c = AudioDub(v, a)

c

ConvertToRGB32()

log_name = "ajk_shake"

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\avisynth_c.dll")
LoadVirtualdubPlugin("C:\Program Files\AviSynth 2.5\plugins\Deshaker.vdf", "Deshaker")
Deshaker("11|2|30|4|1.33333|7|1|0|640|480|1|2|1|400|400|400|1500|4|1|0|2|5|40|300|4|"+log_name+".log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|2|2|1|1|0|0|30|30|0|0|0|0|1|0|0|10|1|15|1000|1")

ConvertToYv12()

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\Deen.dll")
deen("a3d",1,10,8)

loadPlugin("C:\Program Files\AviSynth 2.5\plugins\MaskTools-v1.5.8\MaskTools.dll")
loadPlugin("C:\Program Files\AviSynth 2.5\plugins\MipSmooth.dll")
loadPlugin("C:\Program Files\AviSynth 2.5\plugins\MSharpen.dll")
import("C:\Program Files\AviSynth 2.5\plugins\DeRainbow.avs")
DeRainbow()
To encode the file, I simply do this:
Code:
x264.exe ajk_pass1.avs --progress --qp 20 --sar 4:3 --seek 3920 --frames 450 --output output.mkv
x264.exe ajk_pass2.avs --progress --qp 20 --sar 4:3 --seek 3920 --frames 450 --output output.mkv
Do you have any idea why it wouldn't work? Should I change my x264.exe command to have it generate the log?
Dada_ is offline   Reply With Quote
Old 10th December 2008, 06:28   #5  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
I use this very often to stabilize old anime. It works only for very small shakes that are often present in VHSrips or oldies:
Code:
#Original script by g-force
function stab (clip orig, float "pixaspect"){
pixaspect=default(pixaspect,1)
rep=Repair(orig.TemporalSoften(7,255,255,25,2),orig,mode=16).TemporalSoften(1,255,255,25,2)
source=Interleave(rep,orig,rep)
mdata=DePanEstimate(source, range=1, trust=0, dxmax=1, dymax=1)
return DePan(source, data=mdata, offset=1,pixaspect=pixaspect).SelectEvery(3,2)}
You can simply call it as stab() and add a float for the pixel aspect if the filtered clip is anamorphic.
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 10th December 2008, 12:49   #6  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Quote:
Originally Posted by Dada_ View Post
Do you have any idea why it wouldn't work?
You don't change back to YV12 after using the VDub plugin.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 10th December 2008, 15:36   #7  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
I don't see the point of sending the first pass of Deshaker to an encoder - just dump it, or send it to a fast lossless file and then delete it.

I've always found it easier to Deshake in virtual dub - to a lossless intermediate file if needs be. I understand why you might want to do it from within AVIsynth, e.g. to go straight to an encoder, but this introduces too many disadvantages for me.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 10th December 2008, 19:06   #8  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
Quote:
Originally Posted by 2Bdecided View Post
I don't see the point of sending the first pass of Deshaker to an encoder - just dump it, or send it to a fast lossless file and then delete it.
virtualdub's 'run video analysis pass' works fairly well.
but then some people just want to stick to cli and not bother with opening up a gui like vdub...
__________________
custom x264 builds & patches | F@H | My Specs
kemuri-_9 is offline   Reply With Quote
Old 10th December 2008, 22:07   #9  |  Link
PeaceAnt
also known as GrassHoppeR
 
Join Date: Mar 2006
Location: Poland
Posts: 30
i use mencoder with NUL option for first pass...
Code:
mencoder.exe %%f -o NUL -ovc frameno -nosound -noskip -mc 0
and to render file
Code:
mencoder.exe %%f -o %%~nf.avi -ovc lavc -lavcopts vcodec=mjpeg -oac copy -noskip -mc 0 -ofps 25 -vf crop=1382:1036:29:22,scale=1280:720
pozdrawiam
PeaceAnt is offline   Reply With Quote
Old 10th December 2008, 23:18   #10  |  Link
g-force
Guest
 
Posts: n/a
here's a newer version of the script that thetoof posted. Give it a shot. You might need to play around with dxmax and dymax.

Code:
temp = last.TemporalSoften(7,255,255,25,2)
Interleave(temp.Repair(last.TemporalSoften(1,255,255,25,2)),last)
DePan(last,data=DePanEstimate(last,trust=0,dxmax=10,dymax=10),offset=-1)
SelectEvery(2,0)
-G
  Reply With Quote
Old 1st February 2009, 23:12   #11  |  Link
McCauley
Registered User
 
Join Date: Nov 2006
Posts: 83
Quote:
Originally Posted by g-force View Post
here's a newer version of the script that thetoof posted. Give it a shot. You might need to play around with dxmax and dymax.

Code:
temp = last.TemporalSoften(7,255,255,25,2)
Interleave(temp.Repair(last.TemporalSoften(1,255,255,25,2)),last)
DePan(last,data=DePanEstimate(last,trust=0,dxmax=10,dymax=10),offset=-1)
SelectEvery(2,0)
Added to wiki.
I converted it into a stand alone script, so you just have to call "stab()"

Thanks g-force!
McCauley
McCauley is offline   Reply With Quote
Old 3rd February 2009, 23:17   #12  |  Link
g-force
Guest
 
Posts: n/a
Thanks! Nice work!
  Reply With Quote
Old 6th March 2013, 11:48   #13  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
There is One More Function.
.
Code:
##############################################################################
#
# Original script by g-force converted into a stand alone script by McCauley 
# latest version from December 10, 2008                                      
#
# http://forum.doom9.org/showthread.php?p=1222830#post1222830
#
##############################################################################

LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\repair.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depan.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depanestimate.dll")



function Stab(clip clp, int "range", int "dxmax", int "dymax", float "trust", float "pixaspect")   
{  
  range     = default(range, 1)
  dxmax     = default(dxmax, 4)
  dymax     = default(dymax, 3)
  trust     = default(trust, 0.0)
  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576 (640x480)

  temp  = clp.TemporalSoften(7, 255, 255, 25, 2)
  inter = Interleave(temp.Repair(clp.TemporalSoften(1, 255, 255, 25, 2)), clp)
  mdata = DePanEstimate(inter, range=range, trust=trust, dxmax=dxmax, dymax=dymax)
  DePan(inter, data=mdata, offset=-1, pixaspect=pixaspect)

  return (SelectEvery(2, 0))
} 



#
#
function Stab2(clip clp, int "range", int "dxmax", int "dymax", float "trust", \
               float "pixaspect", float "zoommax", float "rotmax", float "cutoff", \
               bool "rot", int "mirror", bool "addzoom")
{
  range     = default(range, 2)
  dxmax     = default(dxmax, 4)   # 4 : 3
  dymax     = default(dymax, 3)   # 4 : 3
  trust     = default(trust, 2.0)

  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576

  zoommax   = default(zoommax, 1.05)
  rotmax    = default(rotmax, 0.5)
  cutoff    = default(cutoff, 0.1)
  rot       = default(rot, true)
  mirror    = default(mirror, 15)
  addzoom   = default(addzoom, true)

  prv       = range
  nxt       = range

  # Global Motion Stabilization
  # Глобальная стабилизация изображения
  #
  mdata = DePanEstimate(clp,                    \
                        dxmax     = dxmax,      \
                        dymax     = dymax,      \
                        trust     = trust,      \
                        improve   = true,       \
                        zoommax   = zoommax,    \
                        range     = range,      \
                        pixaspect = pixaspect)

  # function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom, \
  #                         int prev, int next, int mirror, int blur, int dxmax, int dymax, \
  #                         float zoommax, float rotmax, int subpixel, float pixaspect, \
  #                         int fitlast, float tzoom, bool info, string inputlog)
  #
  return (DepanStabilize(clp,                      \
                         data      = mdata,        \
                         cutoff    = cutoff,       \ 
                         damping   = 0.9,          \
                         initzoom  = 1.0,          \
                         addzoom   = addzoom,      \
                         prev      = prv,          \
                         next      = nxt,          \
                         mirror    = mirror,       \ 
                         blur      = 50,           \
                         dxmax     = dxmax,        \
                         dymax     = dymax,        \ 
                         zoommax   = zoommax,      \
                         rotmax    = rotmax,       \
                         subpixel  = 2,            \
                         pixaspect = pixaspect,    \
                         fitlast   = 0,            \
                         tzoom     = 3.0,          \
                         info      = false))
}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 7th March 2013, 07:31   #14  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Global motion stabilization.
New functions.
Begin...
.
Code:
##############################################################################
#
# Original script by g-force converted into a stand alone script by McCauley 
# latest version from December 10, 2008                                      
#
# http://forum.doom9.org/showthread.php?p=1222830#post1222830
#
##############################################################################

LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depan.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depanestimate.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\FFT3DFILTER_20070220\fft3dfilter.dll")  
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\repair.dll")


# Function Stab()
#
function Stab(clip clp, int "range", int "dxmax", int "dymax", float "trust", float "pixaspect", \
              float "zoommax", int "mirror")
{  
  range     = default(range, 1)
  dxmax     = default(dxmax, 4)
  dymax     = default(dymax, 3)
  trust     = default(trust, 0.0)
  zoommax   = default(zoommax, 1.0)
  mirror    = default(mirror, 0)

  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576 (640x480)

  temp  = clp.TemporalSoften(7, 255, 255, 25, 2)
  inter = Interleave(temp.Repair(clp.TemporalSoften(1, 255, 255, 25, 2)), clp)

  # DePanEstimate(clip, int range, float trust, int winx, int winy, int dxmax, int dymax, \
  #               float zoommax, bool improve, float stab, float pixaspect, bool info,    \
  #               string log, bool debug, bool show, bool fftw)
  #
  mdata = DePanEstimate(inter,                   \
                        dxmax     = dxmax,       \
                        dymax     = dymax,       \
                        pixaspect = pixaspect,   \
                        zoommax   = zoommax,     \
                        improve   = true,        \
                        range     = range,       \
                        trust     = trust)

  # DePan(clip, clip data, float offset, int subpixel, float pixaspect, bool matchfields, \
  #       int mirror, int blur, bool info, string inputlog) 
  #
  DePan(inter,                      \
        data        = mdata,        \
        pixaspect   = pixaspect,    \
        subpixel    = 2,            \
        mirror      = mirror,       \
        matchfields = true,         \
        blur        = 100,          \
        offset      = -1)

  return (SelectEvery(2, 0))
} 



# Function Stab2()
#
function Stab2(clip clp, int "range", int "dxmax", int "dymax", float "trust", \
               float "pixaspect", float "zoommax", float "rotmax", float "cutoff", \
               bool "rot", int "mirror", bool "addzoom")
{
  range     = default(range, 2)
  dxmax     = default(dxmax, 4)   # 4 : 3
  dymax     = default(dymax, 3)   # 4 : 3
  trust     = default(trust, 2.0)

  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576

  addzoom   = default(addzoom, true)
  zoommax   = default(zoommax, 1.05)
  cutoff    = default(cutoff, 0.1)
  rot       = default(rot, true)
  rotmax    = default(rotmax, 0.5)
  mirror    = default(mirror, 15)


  # Global Motion Stabilization
  # Глобальная стабилизация изображения
  #
  # DePanEstimate(clip, int range, float trust, int winx, int winy, int dxmax, int dymax, \
  #               float zoommax, bool improve, float stab, float pixaspect, bool info,    \
  #               string log, bool debug, bool show, bool fftw)
  #
  mdata = DePanEstimate(clp,                    \
                        dxmax     = dxmax,      \
                        dymax     = dymax,      \
                        pixaspect = pixaspect,  \
                        zoommax   = zoommax,    \
                        improve   = true,       \
                        range     = range,      \
                        trust     = trust)

  # function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom, \
  #                         int prev, int next, int mirror, int blur, int dxmax, int dymax, \
  #                         float zoommax, float rotmax, int subpixel, float pixaspect, \
  #                         int fitlast, float tzoom, bool info, string inputlog)
  #
  return (DepanStabilize(clp,                      \
                         data      = mdata,        \
                         dxmax     = dxmax,        \
                         dymax     = dymax,        \ 
                         prev      = range,        \
                         next      = range,        \
                         pixaspect = pixaspect,    \
                         subpixel  = 2,            \
                         cutoff    = cutoff,       \ 
                         initzoom  = 1.0,          \
                         tzoom     = 3.0,          \
                         addzoom   = addzoom,      \
                         zoommax   = zoommax,      \
                         rotmax    = rotmax,       \
                         mirror    = mirror,       \ 
                         blur      = 100,          \
                         fitlast   = 0,            \
                         damping   = 0.9,          \
                         info      = false))
}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 7th March 2013, 07:33   #15  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Global motion stabilization.
New functions.
Continue...
.
Code:
# Function Stab3()
#
function Stab3(clip clp, int "range", int "dxmax", int "dymax", float "pixaspect", \
               float "zoommax", float "rotmax", float "cutoff", \
               bool "rot", int "mirror", bool "addzoom")
{
  # Constants   
  # MSuper()  
  #  
  blkh      = 8             ## Change this constant, must be 4, 8, 16, 32
  blkv      = 8             ## Change this constant, must be 4, 8, 16, 32
  pel       = 4
  chroma    = true
  isse      = true
  
  # Constants   
  # MAnalyse()  
  #  
  blkh2     = blkh * 2      # Must be 4, 8, 16, 32
  blkv2     = blkv * 2      # Must be 4, 8, 16, 32
  (blkh2 > 32) ? 32 : blkh2
  (blkv2 > 32) ? 32 : blkv2
  overlap   = blkh2 / 2
  overlapV  = blkv2 / 2
  lambda    = 100 * blkh2 * blkv2 / 64
  lsad      = 400 * blkh2 * blkv2 / 64


  # Default variables values
  #
  dxmax     = default(dxmax, 4)   # 4 : 3
  dymax     = default(dymax, 3)   # 4 : 3
  range     = default(range, 2)

  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576

  zoommax   = default(zoommax, 1.05)
  rotmax    = default(rotmax, 0.5)
  cutoff    = default(cutoff, 0.1)
  rot       = default(rot, true)
  mirror    = default(mirror, 15)
  addzoom   = default(addzoom, true)


  # Global Motion stabilization
  # Глобальная стабилизация изображения
  #
  # function FFT3DFilter(clip, float "sigma", float "beta", int "plane", int "bw", int "bh", int "bt", int "ow", int "oh", \
  #                      float "ratio", float "sharpen", float "scutoff", float "svr", float "smin", float "smax", bool "measure", \
  #                      bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow", float "pcutoff", \
  #                      float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", \
  #                      float "hr", float "ht", int "ncpu")
  #
  prefiltered = FFT3DFilter(clp,                \
                            sigma      = 3,     \
                            plane      = 4,     \
                            bt         = 4,     \
                            sharpen    = 0.75,  \
                            interlaced = false, \
                            dehalo     = 1.0,   \
                            ncpu       = 2)

  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  prefilteredSuper = MSuper(prefiltered,      \
                            hpad    = blkh,   \
                            vpad    = blkv,   \
                            pel     = pel,    \
                            levels  = 1,      \
                            chroma  = chroma, \
                            sharp   = 2,      \
                            rfilter = 4,      \
                            isse    = isse,   \
                            planar  = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  vectors = MAnalyse(prefilteredSuper,        \
                     blksize     = blkh2,     \
                     blksizeV    = blkv2,     \
                     overlap     = overlap,   \
                     overlapV    = overlapV,  \
                     isb         = false,     \
                     chroma      = chroma,    \
                     delta       = 1,         \
                     truemotion  = false,     \ 
                     global      = true,      \
                     dct         = 5,         \
                     search      = 5,         \
                     searchparam = 8,         \  
                     plevel      = 0,         \
                     divide      = 0,         \
                     pnew        = 25,        \
                     lsad        = lsad,      \
                     lambda      = lambda,    \
                     badSAD      = 400,       \
                     temporal    = true,      \
                     isse        = isse)

  # function MDepan(clip, clip vectors, clip "mask", bool "zoom", bool "rot", float "pixaspect", float "error", bool "info", \
  #                 string "log", float "wrong", float "zerow", int "range", int "thSCD1", int "thSCD2", bool "isse", bool planar) 
  #
  globalmotion = MDepan(prefiltered,             \
                        vectors,                 \
                        pixaspect = pixaspect,   \
                        range     = range,       \
                        zoom      = addzoom,     \
                        rot       = rot,         \
                        error     = 80.0,        \
                        wrong     = 3.0,         \
                        zerow     = 0.05,        \
                        thSCD1    = 625,         \
                        thSCD2    = 160,         \
                        isse      = isse,        \
                        info      = false,       \
                        planar    = false)

  # function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom, \
  #                         int prev, int next, int mirror, int blur, int dxmax, int dymax, \
  #                         float zoommax, float rotmax, int subpixel, float pixaspect, \
  #                         int fitlast, float tzoom, bool info, string inputlog)
  #
  return (DepanStabilize(clp,                      \
                         data      = globalmotion, \
                         dxmax     = dxmax,        \
                         dymax     = dymax,        \ 
                         prev      = range,        \
                         next      = range,        \
                         pixaspect = pixaspect,    \
                         subpixel  = 2,            \
                         rotmax    = rotmax,       \
                         initzoom  = 1.0,          \
                         tzoom     = 3.0,          \
                         addzoom   = addzoom,      \
                         zoommax   = zoommax,      \
                         mirror    = mirror,       \ 
                         blur      = 300,          \
                         cutoff    = cutoff,       \ 
                         damping   = 0.9,          \
                         fitlast   = 0,            \
                         info      = false))
}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 7th March 2013, 07:34   #16  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Global motion stabilization.
New functions.
End...
.
Code:
# Function Stab4()
#
function Stab4(clip clp, int "range", int "dxmax", int "dymax", float "pixaspect", \
               float "zoommax", float "rotmax", float "cutoff", \
               bool "rot", int "mirror", bool "addzoom")
{
  # Constants   
  # MSuper()  
  #  
  blkh         = 8          ## Change this constant, must be 4, 8, 16, 32
  blkv         = 8          ## Change this constant, must be 4, 8, 16, 32
  pel          = 4
  chroma       = true
  isse         = true
  sharp        = 2
  rfilter      = 2

  # Constants   
  # MAnalyse()  
  #  
  blkh2        = blkh * 2   # Must be 4, 8, 16, 32
  blkv2        = blkv * 2   # Must be 4, 8, 16, 32
  (blkh2 > 32) ? 32 : blkh2
  (blkv2 > 32) ? 32 : blkv2
  overlap2     = blkh2 / 2
  overlapV2    = blkv2 / 2
  lambda       = 100 * blkv2 * blkh2 / 64
  lsad         = 400 * blkv2 * blkh2 / 64
  dct          = 5
  search       = 5
  searchparam  = 8
  pnew         = 25
  truemotion   = false

  # Constants
  # MRecalculate()
  #
  blkhR        = blkh       # Must be 4, 8, 16, 32
  blkvR        = blkv       # Must be 4, 8, 16, 32
  overlapR     = blkhR / 2
  overlapVR    = blkvR / 2
  lambdaRecalc = 100 * blkvR * blkhR / 64


  # Default variables values
  #
  dxmax     = default(dxmax, 4)   # 4 : 3
  dymax     = default(dymax, 3)   # 4 : 3
  range     = default(range, 2)

  pixaspect = default(pixaspect, 1.094)   # PAL 720x576
#  pixaspect = default(pixaspect, 1.0)     # PAL 768x576

  zoommax   = default(zoommax, 1.05)
  rotmax    = default(rotmax, 0.5)
  cutoff    = default(cutoff, 0.1)
  rot       = default(rot, true)
  mirror    = default(mirror, 15)
  addzoom   = default(addzoom, true)


  # Global Motion Stabilization
  # Глобальная стабилизация изображения
  #
  # function FFT3DFilter(clip, float "sigma", float "beta", int "plane", int "bw", int "bh", int "bt", int "ow", int "oh", \
  #                      float "ratio", float "sharpen", float "scutoff", float "svr", float "smin", float "smax", bool "measure", \
  #                      bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow", float "pcutoff", \
  #                      float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", \
  #                      float "hr", float "ht", int "ncpu")
  #
  prefiltered = FFT3DFilter(clp,                \ 
                            sigma      = 3,     \
                            plane      = 4,     \
                            bt         = 4,     \
                            sharpen    = 0.75,  \
                            interlaced = false, \
                            dehalo     = 1.0,   \
                            ncpu       = 2)

  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  prefiltered2 = MSuper(clp,                 \
                        hpad    = blkh,      \
                        vpad    = blkv,      \
                        pel     = pel,       \
                        levels  = 0,         \
                        chroma  = chroma,    \
                        sharp   = sharp,     \
                        rfilter = rfilter,   \
                        isse    = isse,      \
                        planar  = false)

  # function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
  #                 int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
  #
  prefilteredSuper = MSuper(prefiltered,         \
                            hpad    = blkh,      \
                            vpad    = blkv,      \
                            pel     = pel,       \
                            levels  = 1,         \
                            chroma  = chroma,    \
                            sharp   = sharp,     \
                            rfilter = rfilter,   \
                            isse    = isse,      \
                            planar  = false)

  # function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam",        \
  #                   int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion",       \
  #                   int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
  #                   int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD",         \
  #                   int "badrange", bool "isse", int "full", bool "meander", bool "temporal") 
  #
  vectors = MAnalyse(prefiltered2,                \
                     blksize     = blkh2,         \
                     blksizeV    = blkv2,         \
                     overlap     = overlap2,      \
                     overlapV    = overlapV2,     \
                     isb         = false,         \
                     chroma      = chroma,        \
                     delta       = 1,             \
                     temporal    = true,          \
                     search      = search,        \
                     searchparam = searchparam,   \  
                     dct         = dct,           \
                     plevel      = 0,             \
                     pnew        = pnew,          \
                     lambda      = lambda,        \
                     lsad        = lsad,          \
                     truemotion  = truemotion,    \ 
                     global      = true,          \
                     divide      = 0,             \
                     badSAD      = 400,           \
                     isse        = isse)

  # function MRecalculate(clip super, clip vectors, int "thSAD", int "smooth", int "blksize", int "blksizeV",   \
  #                       int "search", int "searchparam", int "lambda", bool "chroma", bool "truemotion",      \
  #                       int "pnew", int "overlap", int "overlapV", string "outfile", int "dct", int "divide", \
  #                       int "sadx264", bool "isse") 
  #
  vectorsRecalc = MRecalculate(prefilteredSuper,            \
                               vectors,                     \
                               blksize     = blkhR,         \
                               blksizeV    = blkvR,         \
                               overlap     = overlapR,      \
                               overlapV    = overlapVR,     \
                               search      = search,        \
                               searchparam = searchparam,   \
                               dct         = dct,           \
                               lambda      = lambdaRecalc,  \
                               pnew        = pnew,          \
                               truemotion  = truemotion,    \
                               thsad       = 100)

  # function MDepan(clip, clip vectors, clip "mask", bool "zoom", bool "rot", float "pixaspect", float "error", bool "info", \
  #                 string "log", float "wrong", float "zerow", int "range", int "thSCD1", int "thSCD2", bool "isse", bool planar) 
  #
  globalmotion = MDepan(prefiltered,             \
                        vectorsRecalc,           \
                        zoom      = addzoom,     \
                        rot       = rot,         \
                        pixaspect = pixaspect,   \
                        error     = 80.0,        \
                        info      = false,       \
                        wrong     = 3.0,         \
                        zerow     = 0.05,        \
                        range     = range,       \
                        thSCD1    = 625,         \
                        thSCD2    = 160,         \
                        isse      = isse,        \
                        planar    = false)

  # function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom,     \
  #                         int prev, int next, int mirror, int blur, int dxmax, int dymax, \
  #                         float zoommax, float rotmax, int subpixel, float pixaspect,     \
  #                         int fitlast, float tzoom, bool info, string inputlog)
  #
  return (DepanStabilize(clp,                      \
                         data      = globalmotion, \
                         dxmax     = dxmax,        \
                         dymax     = dymax,        \ 
                         prev      = range,        \
                         next      = range,        \
                         pixaspect = pixaspect,    \
                         subpixel  = 2,            \
                         initzoom  = 1.0,          \
                         tzoom     = 3.0,          \
                         addzoom   = addzoom,      \
                         zoommax   = zoommax,      \
                         mirror    = mirror,       \ 
                         rotmax    = rotmax,       \
                         blur      = 300,          \
                         cutoff    = cutoff,       \
                         damping   = 0.9,          \
                         fitlast   = 0,            \
                         info      = false))

}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 7th March 2013, 12:35   #17  |  Link
lisztfr9
Registered User
 
Join Date: Apr 2010
Posts: 175
Quote:
Originally Posted by g-force View Post
here's a newer version of the script that thetoof posted. Give it a shot. You might need to play around with dxmax and dymax.

Code:
temp = last.TemporalSoften(7,255,255,25,2)
Interleave(temp.Repair(last.TemporalSoften(1,255,255,25,2)),last)
DePan(last,data=DePanEstimate(last,trust=0,dxmax=10,dymax=10),offset=-1)
SelectEvery(2,0)
-G
Are you sure you need the repair filter here ?

Thanks, L
lisztfr9 is offline   Reply With Quote
Old 7th March 2013, 14:28   #18  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724
I could try to make a stabilization plugin. But there's a problem. How do I deal with subpixel offset? I understand how to move pixels by integer offset, but how do I deal with fractional? Do I have to fit a surface and inpaint the interpolated values?
__________________
...desu!
Mystery Keeper is offline   Reply With Quote
Old 9th March 2013, 18:29   #19  |  Link
SEt
Registered User
 
Join Date: Aug 2007
Posts: 374
You can use resize algorithm with scaling factor 1 for that.
SEt is offline   Reply With Quote
Old 12th November 2017, 03:17   #20  |  Link
alexx7777
Registered User
 
Join Date: Mar 2012
Posts: 69
I can not understand in any way what better values ​​to set for dxmax and dymax function Stab () to remove strong shaking (720x576, 50p)?
alexx7777 is offline   Reply With Quote
Reply

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 03:12.


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