digitalFAQ.com Forum

digitalFAQ.com Forum (http://www.digitalfaq.com/forum/)
-   Restore, Filter, Improve Quality (http://www.digitalfaq.com/forum/video-restore/)
-   -   VCR simulator script, Avisynth fake VHS look! (http://www.digitalfaq.com/forum/video-restore/2792-vcr-simulator-script.html)

jmac698 01-12-2011 09:13 AM

VCR simulator script, Avisynth fake VHS look!
 
1 Attachment(s)
Simulates SLP VHS recording. Besides being a special effect, can be used to test various plugins that clean up recordings, in a scientific way.
Code:

#VCR line jitter simulator by jmac698
#requires both gscript and grunt
colorbars(pixel_type="YUY2").trim(0,10)
pointresize(width,height*4)#get line resolution by working around min height 4 limitations
h=height
splitlines(4)#split to lines of height 2 - note the jitter function requires height>=4
jitter
#return last
MergeLines(h)#merge until height=h, note why do I need blankclip(height=480)?
blur(1).blur(1).blur(1)
pointresize(width,height/4)
temp=last
u=temp.utoy
v=temp.vtoy
u=u.bilinearresize(30,height).bilinearresize(320,height)#it's actually better than this, placement of transitions is finer
v=v.bilinearresize(30,height).bilinearresize(320,height)
ytouv(u,v,temp)

function SplitLines(clip c, int n) {
  Assert(c.height%n == 0, "Clip height not a multiple of 'n'")
  Assert(!(c.IsYV12() && n%2==1), "'n' must be even for YV12 clips")
  nStrips = c.height/n
  c = c.ChangeFPS(nStrips*Framerate(c)).AssumeFPS(c) # Repeat each frame 'nStrips' times
  BlankClip(c, height=n) # template for ScriptClip result
  GScriptClip("c.Crop(0, (current_frame%nStrips)*n, 0, n)", args="c, nStrips, n")
}

function MergeLines(clip c, int h) {
  n=h/c.height #n is number of frames to merge, e.g. 480 split to 2line has n=240
  c.SelectEvery(n)
  GScript("""
    for (i=1, n-1) {
      stackvertical(c.SelectEvery(n, i))
    }
  """)
}

function shift(clip v, int sx, int sy) {
  v#shift a video sx, sy pixels, sx<0 is left, sy<0 is down
  pointresize(width*2,height*2)#to allow 1 pixel shifts in YV12
  sx=sx*2
  sy=sy*2
  l=(sx<0)?-sx:0
  r=(sx<0)?0:sx
  t=(sy<0)?0:sy
  b=(sy<0)?-sy:0
  crop(l,t,-r,-b)
  addborders(r,b,l,t)
  bilinearresize(v.width,v.height)
}

function jitter(clip v) {#note: a good tape could typically be +-3 without a TBC, distribution is not realistic
  ScriptClip(v,"""
    shift(rand(6)+4,0)
  """)
}


lordsmurf 02-12-2018 06:17 AM

I still haven't tried this.
I've always tried to make VHS look better, so making video look worse just feels wrong. :P


All times are GMT -5. The time now is 11:34 AM

Site design, images and content © 2002-2021 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2021 Jelsoft Enterprises Ltd.