VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. I have a source I am using a stabilizer on. I have used it one multiple things but I never seen this happen before.

    It is stabilizing the video fine as usual, but many scenes it is making the video jerk/bounce back and forth from left to right really quickly, and it does not do that without the stabilizer filter.

    Is there a way to stabilize only up and down motion and leave left and right motion alone? This source video bounces up and down a lot and constantly from beginning to end, but I never see it move from left to right. I think if I could get the stabilizer to not bother moving left or right, I might be able to fix this issue?

    I have tried both the Stab and Stab2 filters.
    Last edited by killerteengohan; 20th May 2020 at 09:18.
    Quote Quote  
  2. Here a demuxed sample video. As you can see, this video is constantly bouncing up and down, and only up and down.

    https://mega.nz/file/p44nSCYC#uwVNRL4FqnRMUZop7nRHjidwQfdb9RUYj6F8RVJM1pE


    Script being used

    (NON STABILIZED)

    Code:
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\dgindex\DGDecode.dll")
    DGDecode_mpeg2source("C:\Users\Admin\Desktop\Encoding\Phantom 2040\The Ghost Who Walks\VTS_01_1.d2v", info=3)
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\avisynth_plugin\ColorMatrix.dll")
    bifrost(scenelumathresh=4)
    ColorMatrix(hints=true, interlaced=true, threads=0)
    tcomb(mode=0)
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\avisynth_plugin\TIVTC.dll")
    tfm(order=1).tdecimate(mode=1,hybrid=0)
    crop( 12, 4, -12, -4)
    LanczosResize(640,480) # Lanczos (Sharp)
    dehalo_alpha(rx=1.1, ry=1.1, darkstr=0, lowsens=0, highsens=50, ss=1.0)
    hqdering(smoother=deen("c3d",1,3,9,2))
    xaa(mode="div2 nnedi3", mask=0, chroma=0, nns=4, cstr=0, mthr=8, mtype="TEMmod1")
    mergechroma(awarpsharp2(depth=4, blur=1, type=1))
    LimitedSharpenFaster(ss_x=1.00, ss_y=1.00, strength=10, overshoot=0, undershoot=0, soft=0, edgemode=0)

    (( STABILIZED ))

    Code:
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\dgindex\DGDecode.dll")
    DGDecode_mpeg2source("C:\Users\Admin\Desktop\Encoding\Phantom 2040\The Ghost Who Walks\VTS_01_1.d2v", info=3)
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\avisynth_plugin\ColorMatrix.dll")
    bifrost(scenelumathresh=4)
    ColorMatrix(hints=true, interlaced=true, threads=0)
    tcomb(mode=0)
    LoadPlugin("C:\Program Files (x86)\MeGui\tools\avisynth_plugin\TIVTC.dll")
    tfm(order=1).tdecimate(mode=1,hybrid=0)
    stab2(range=1, dxmax=4, dymax=4, uvfix=false)
    crop( 12, 4, -12, -4)
    LanczosResize(640,480) # Lanczos (Sharp)
    dehalo_alpha(rx=1.1, ry=1.1, darkstr=0, lowsens=0, highsens=50, ss=1.0)
    hqdering(smoother=deen("c3d",1,3,9,2))
    xaa(mode="div2 nnedi3", mask=0, chroma=0, nns=4, cstr=0, mthr=8, mtype="TEMmod1")
    mergechroma(awarpsharp2(depth=4, blur=1, type=1))
    LimitedSharpenFaster(ss_x=1.00, ss_y=1.00, strength=10, overshoot=0, undershoot=0, soft=0, edgemode=0)

    I included a scene that shows the left and right rapid jerking quite a bit. It happens when the guy is rubbing his hands together, and when the other guy in sunglasses starts following the kid. This left and right jerking is happening way too much and very visible if you stare at the left side of the image.

    If there is a way to only effect the up and down motions, that would be great because I cannot stand the constant bouncing up and down.
    Last edited by killerteengohan; 21st May 2020 at 00:20.
    Quote Quote  
  3. For stab variants - if you use dxmax=0, then horizontal will be limited to 0 pixels (ie not work)
    Quote Quote  
  4. It will not let me use dxmax=0. dymax=0 works, but not dxmax for some reason.

    Quote Quote  
  5. That specific line in the avsi fie it is referring to says this
    Code:
    crop(width-cropx,0,0,0).conditionalfilter(last,clp,ratiox,">","0")""") : last
    Quote Quote  
  6. It looks like he added additional logic for stab2 , and dxmax has to = dymax for that version

    You can use the original stab or one of the other variants
    Quote Quote  
  7. It doesn't exactly have to = dymax for the filter to work. They can both be different. The notes in avsi file says otherwise, but it works when I try different numbers. Its just the dxmax=0 that will not work. I tried using dxmax=1, but its still too much and doing that jerking left and right.


    I can get it to work if I remove this entire section from stab2.avsi. It has to be the entire section or it wont work.

    Code:
    # from depansafe() function
    FixFalPos ? eval("""
    thick = 2.0  # removing >2px wide borders
    cropx = ceil(dxmax)*2
    ratiox = "YPlaneMax("+string(ceil(99-thick/cropx*100))+")"
    
    crop(0,0,0,cropx).conditionalfilter(last,clp,ratiox,">","0")
    crop(0,height-cropx,0,0).conditionalfilter(last,clp,ratiox,">","0")
    crop(0,0,cropx,0).conditionalfilter(last,clp,ratiox,">","0")
    crop(width-cropx,0,0,0).conditionalfilter(last,clp,ratiox,">","0")""") : last
    I don't know if I would be ruining it though. It looks like it works like that. Does that section look important to you?
    fixfalpos isnt really important and I don't use it anyways so I doubt removing that one line is a problem. I don't know about the rest though or exactly what its doing. I tried changing the > into < but that didn't do anything or get it to work.
    Last edited by killerteengohan; 21st May 2020 at 02:17.
    Quote Quote  
  8. I figured it out. I did not know fixfalpos was on by default. That fixes 3 pixel wide black borders that can appear after stabilization. I just set it to false and it works now.

    Thanks for the suggestion about dxmax. I was not aware I could use 0 to disable x movement.
    Quote Quote  
  9. Both Stab and Stab2 work and the scripts finished. Thanks again for that suggestion.

    For some reason though, it did not affect the video stabilization any. Even if both dxmax and dymax are 4-15 and or I raise the range up some more, It's still constantly bouncing up and down. That just will not quit for some reason.

    Maybe its because this movement isn't like normal instability? Instead of a quick up and down motion, the whole screen moves up, then about 10-20 frames later the whole screen moves down and it constantly repeats this and the amount it moves seems to be the same all the time. I tried raising the range up to 30, but it didn't help.

    Are you able to get it to stop that with that sample I provided?
    Last edited by killerteengohan; 21st May 2020 at 02:47.
    Quote Quote  
  10. Your up/down jumps are too low in frequency (every 16 or 17 frames) for stab. You can try changing the range variable but I've never seen it work with such slow jumps.
    Quote Quote  
  11. I did try raising the range already as mentioned in my last comment.

    Is there an alternative, or possibly a good way to manually stabilize each set of moving frames? I suppose I might be able to go through frame by frame, and manually move each set of moving frames up or down if I knew how to do that. I have no idea how to manually adjust an entire frame up or down by 1-2px manually though.
    Quote Quote  
  12. You can crop and addborders to adjust up or down

    But the pattern is not consistent (sometimes 17, sometimes 16, etc....) . If it was repeating pattern, it would be "easy', you could use the select functions
    Quote Quote  
  13. You could use ReplaceFramesSimple() to select from two (or more) versions of the video, one shifted up by a scan line the other not.

    Code:
    Stab()
    ShiftedUp = last.Crop(0,1,-0,-0).AddBorders(0,0,0,1)
    ReplaceFramesSimple(last, ShiftedUp, frames="[0 16]  [33 49]") # replace frames 0-16 and 33.49 of last with frames from ShiftedUp.
    You would have to go through the video manually to find all the ranges.

    I believe it could be automated with a complex script with runtime functions. But that's more work than I want to perform.
    Quote Quote  
  14. Says I have to crop by mod2 in YV12, so unless I want to change to YV24 or something, I will have to use mod2 I guess.
    ReplaceFramesSimple had no argument named frames=, I had to change it to mappings=

    Code:
    ShiftedUp = last.Crop(0,2,-0,-0).AddBorders(0,0,0,2)
    ReplaceFramesSimple(last, ShiftedUp, mappings="[17238 18000] [19000 20000]")

    Thanks, I never thought of simply using crop and addborders to shift an entire image. I feel kind of dumb for not thinking of that.

    Why is it that I have to crop by mod2 in YV12, but the stabilizer stab/stab2 can crop or move the image by 1 if it wants? Is there another way to move the entire screen around without cropping or addborders?
    Quote Quote  
  15. Originally Posted by killerteengohan View Post

    Why is it that I have to crop by mod2 in YV12, but the stabilizer stab/stab2 can crop or move the image by 1 if it wants? Is there another way to move the entire screen around without cropping or addborders?

    Short expanation - 4:2:0 chroma subsampling . You don't have full color samples, only 1/2 width , 1/2 height samples, so there are crop restrictions. Each group of 2x2 Y' pixels shares a CbCr chroma sample.
    http://avisynth.nl/index.php/Crop#Crop_restrictions

    full pixel, or even subpixel movement can occur when you resample. i.e you are "resizing" the frame. Internally that's what any of the subpixel filters are using (crop and resize) .
    eg. avs internal resizers have src_left=, src_top=, src_width=, src_height= , which are applied before the resize step; so that's how subpixel shifting is done
    http://avisynth.nl/index.php/Resize#Common_Parameters

    But resizing is lossy in general (some exceptions with true nearest neighbor on 2x multiples) , and can soften the picture. You can't see it on this source, but if you had a high quality source, you should notice that stabilized frames are often softer, even if you disable zoom. In contrast, (legal) full pixel cropping, adding borders just shift the picture, and there is no additional loss in the script
    Quote Quote  
  16. Originally Posted by killerteengohan View Post
    ReplaceFramesSimple had no argument named frames=, I had to change it to mappings=
    Sorry. I just typed it from memory and got the variable name wrong.

    Originally Posted by killerteengohan View Post
    Why is it that I have to crop by mod2 in YV12, but the stabilizer stab/stab2 can crop or move the image by 1 if it wants? Is there another way to move the entire screen around without cropping or addborders?
    Cropping and adding border always has to be done mod 2 with YV12 because the chroma planes are half the width/height of the luma plane and neither allows half-pixel operations. If you shift up by two lines you will still have the bounce problem. Instead of bouncing down by a pixel the sections will now bounce up by a pixel. You'll have to work in YUY2, YV24, or RGB. Here's a section of the video before (left) and after (right):

    Code:
    ConvertToYV24()
    Stab(dxmax=0, range=5)
    ShiftedUp = last.Crop(0,1,-0,-0).AddBorders(0,0,0,1)
    ReplaceFramesSimple(last, ShiftedUp, mappings="[87 103] [120 136] [154 169] [187 203] [220 236] [254 269] [287 303] [320 336] [354 369] [387 403] [420 436] [454 469] [487 503]")
    ConvertToYV12()
    Image Attached Files
    Quote Quote  
  17. Doesn't stab and stab2 work in YV12 though? It doesn't seem to have a problem moving in any direction by only one pixel. Is it screwing up the chroma when it does that?
    Quote Quote  
  18. Stab resamples the image. It doesn't just shift it around. Think of it like this: you can double the width and height of your YV12 image, shift the image up by two scan lines, the downscale back to the original size. The net effect is you've moved the frame up by one scan line.
    Quote Quote  
  19. Ah, I did not know that's how it operated. Thanks for clarifying that.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!