I decided I should probably start my own thread for archival purposes rather than posting in Mathmax's previous thread (https://forum.videohelp.com/threads/317881-improve-old-VHS). I've been taking a break from my own thread and decided to try this script on a VOB of which I do not have access to the original VHS and suffers badly from time base errors. I'm using the script below as suggested by mathmax to strengthen the edges but have no clue how to now apply these edges onto my original video?? and then run DeJitter:
Script:
LoadPlugin("C:\Program Files\Avisynth 2.5\Plugins\DGDecode.dll")
MPEG2Source("Cher - Episode 25 PART 1.d2v")
PointResize(width, height * 2)
ConvertToYV12()
Levels(16, 1, 235, 0, 255, coring=false)
ProcessLine(0)
PointResize(width, height / 2)
function ProcessLine(clip c, int n)
{
cropl = c.Crop(0,n*2,36,2)
newcropl = ScriptClip(cropl, """
black = int(AverageLuma(Crop(0,0,6,2))) #get the average luma of the left pixels
white = int(AverageLuma(Crop(30,0,6,2))) #get the average luma of the right pixels
oldwhite = white
l = 30
gamma = 1.9 - (Float(oldwhite)/Float(255))
#WriteFile("c:\output.txt", "oldwhite")
#WriteFile("c:\output.txt", "Float(oldwhite)/Float(255)")
#WriteFile("c:\output.txt", "gamma")
white = white > l ? l : white
black = black > l ? l : black
margin = (white - black)/5
Levels(black + margin, gamma, white, 0, 255, coring=false) #adjust the level to make the left real black and right real white.
""")
cropr = c.Crop(684,n*2,36,2)
newcropr = ScriptClip(cropr, """
white = int(AverageLuma(Crop(0,0,6,2))) #get the average luma of the left pixels
black = int(AverageLuma(Crop(30,0,6,2))) #get the average luma of the right pixels
l = 40
oldwhite = white
gamma = 1.9 - (Float(oldwhite)/Float(255))
white = white > l ? l : white
black = black > l ? l : black
margin = (white - black)/5
Levels(black + margin, gamma, white, 0, 255, coring=false) #adjust the level to make the left real black and right real white.
""")
newcrop = StackHorizontal(newcropl, newcropr)
return (n < 239) ? StackVertical(newcrop, ProcessLine(c, n + 1)) : newcrop
}
Video sample:
http://www.mediafire.com/?ju51r5twcuo853p
Here is what VirtualDub is showing when I open the above script:
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 30 of 50
Thread
-
-
Mathmax wasn't able to help? Well I could put those edges back on the video, but I don't think they are doing much to help the dejitter plugin. My own script is still in development and I haven't touched it this week. I know I'll solve it eventually but I feel like I have to go back to basic research to make good improvements.
I'm working on writing actual plugins today, they are much faster than the scripting I've been doing. This will be important to make my ideas more practical. -
I really look forward to seeing your progress. Many said it couldn't be done!! Btw I think the above edges are black before the video starts...I don't know if that changes if the following color frames would work better and actually would improve dejitter's results or not. Haven't heard from mathmax yet but I'm sure I will
Last edited by Cherbette; 3rd Nov 2011 at 08:50.
-
Hey, that's a really cool sample to me.. has some interesting possibilities... I think I'll work on it
-
Ok, my script worked in sections of the video that are bright enough... see what you think.
http://www.sendspace.com/file/0xvqr5
Sample:
http://screenshotcomparison.com/comparison/91853Last edited by jmac698; 3rd Nov 2011 at 10:21.
-
I really think that is fantastic, honestly!! Brilliant! Now, if I can figure out something to do with the darker scenes haha There are a slew of other problems with this video as well which I will attempt to address once I get the time base errors corrected. When I try to run the script posted in your thread over at doom9 on my video I get the following error: "ScriptClip: Function did not return a video clip of the same colorspace as the source clip!"
Also, do you think that enhancing the edges in the way mathmax did for his Michael Jackson video would make your script more effective on the darker portions of the video?Last edited by Cherbette; 3rd Nov 2011 at 10:59.
-
Ok, I didn't want to say anything, but I was quite impressed myself - I think I experienced what the average person must react, it felt like magic to me. However my script is a very simple concept and I can't claim I did anything brilliant here, it just happens to make an impressive result.
Anyhow here's the dejitter portion of script which I used:
Code:#Fast line shifter Ver 0.52 by jmac698 #Lines up either or both edges of a video. Can also be used as displacement for 3d scripts. #Requires Masktools v2a45+ (mt_lutspa mode), GScript http://forum.doom9.org/showthread.php?t=147846 #MinMax http://forum.doom9.org/showthread.php?p=1532124#post1532124 #Modified to work with Cherbette's sample (also required dgdecode and a dgindex *.d2v for the source video) #warning this is extremely slow src=Mpeg2Source("D:\project001a\sampleproblem5\Untitled.d2v").converttoyuy2.crop(8,0,0,0).trim(555,555+117) thresh=32 ScriptClip(src, """ #Mark video edges converttoyv12 m=mt_binarize(thresh) #Line up video findpos_h(m, searchwidth=22) alignbyluma(src,last) """) converttoyv12 #I used the lines below in another script for a 2nd pass at the video. Don't enable here they are ridiculously slow and likely to crash. #MCTemporalDenoise(settings="high") #QTGMC( Preset="Slow" , Sharpness=1.2, SLMode=1).selecteven function findpos_h(clip m, int "searchwidth", int "x1", int "x2"){ #Searches m from left to right in the range x1 to x1+searchwidth-1 and right to left in the range width-1-x2 to x2-searchwidth-1 #for the first luma=255 pixel, then colors the output line with the offset from x #for example m is 0 0 255 255 255 0 0 0, width=8, x1=0, x2=0, searchwidth=4 becomes 4 4 2 3 3 4 4 4, then 2 2 2 2 3 3 3 3 #Can only search for 255 pixels (as the luma output is only 8 bit) #c and m should have the same clip properties (same size) #searchwidth should be <=width/2 searchwidth=default(searchwidth,32) x1=default(x1,0) x2=default(x2,0) rampexpr="x "+string(m.width/2)+" < x "+string(m.width-1)+" x - ?"#x w/2 < x w-1 x - ? ramp=mt_lutspa(m, mode="absolute",expr=rampexpr) notfound=searchwidth#Value to return if no mask on this line, should be >=searchwidth or you'll find the wrong minimum later maskmarker=255#The luma value in the mask which indicates a detected pixel #(if m=maskmarker return ramp else notfound), 255 means x>=255, x<searchwidth or notfound mt_lutxy(m,ramp,yexpr="x "+string(maskmarker)+" = y "+string(notfound)+" ?") #now make solid lines based on min luma found in each line l=crop(0,0,-width/2,0) r=crop(width/2,0,0,0) l=l.minmax(0,0) r=r.minmax(0,0) StackHorizontal(l,r) } function alignbyluma(clip src, clip shift, int "mode"){ #Shift/scale each line of clip src by the x offset defined by the luma of shift #for example if shift were all luma=8, the entire src clip would move 8 pixels to the (dir) #This works on a pixel basis, so solid horizontal lines in shift can shift src by variable amounts per line #It uses a simple replacement strategy, where each pixel in shift is tested and replaced by the same pixel in a shifted copy #Currently handles only 0-15 shifts #Magnify everything to get full color resolution mode=default(mode, 2) shiftuv=shift shift=shift.pointresize(shift.width*2,shift.height*2) shift=ytouv(shiftuv,shiftuv,shift) src=src.pointresize(src.width*2,src.height*2)#We double here to preserve chroma rez GScript(" for (y=0, src.height/2-1, 1) { l=int(getpixel(shift,0,y).YPlaneMin) r=int(getpixel(shift,shift.width/2-2,y).YPlaneMin) getline(src, y*2) align(l*2, r*2, 12, 4) out=y==0?last:stackvertical(out,last) }#for y ")#GScript out converttoyuy2 bilinearresize(src.width/2,src.height/2) } function align(clip v, int xl, int xr, int lb, int rb, int "mode") { v#shift an image, x>0 shifts left, xl is amount to shift left, xr is amount to shift right #mode 0 is shift left only, 1 shift right, 2 scale to shift left and right mode=default(mode, 2) offx=mode==0?xl:-xr mode<2?pointresize(last.width, last.height, offx, 0, last.width, last.height):crop(xl,0,-xr,0).addborders(lb, 0, rb, 0).Spline36Resize(last.width,last.height) } function getpixel(clip v, int x, int y) { #get color of a single pixel and return as a fat 2x2 yv12 pixel v #pointresize(last.width*2,last.height*2) crop(x>0?x*2:0,y>0?y*2:0,-(last.width-x*2-2),-(last.height-y*2-2)) } function getline(clip v, int y) { v#return a line of height 2 from y to y+1 crop(0,y,0,-(last.height-y-2)) } function findthresh(clip v){ #Find a resonable starting point for thresh by searching border current_frame=0 v.converttoyv12 crop(0,16,-last.width+2,-16) AverageLuma }
-
Also requires GRunT: http://forum.doom9.org/showthread.php?t=139337
-
I also added deblocking to the Mpeg2Source line and used VirtualDub's Camcorder Denoise to remove some of the chroma noise and adjusted the gamma slightly. This video is extremely BRIGHT and it has blown away much of the detail. It is supposedly 2nd generation from the CBS master tape but it must have been dubbed poorly. It has not been aired in full since 1976...vh1 aired a 30 minute edited version years ago when "Believe" hit it big.
I would like to thank jmac for his advances with this software TBC. Hopefully I can figure something out for the darker scenes as well -
Oh really?? I look forward to that as well *does happy dance*
Thank you so much for your help -
Just be patient, I have t work too you know
Anyhow, it seems to me that I can take parts which work perfect and track their motion into a bad area. It will only be an improved probability to cover more areas. The remaining areas will still be bad. But first I got to make this thing faster as it's driving me nuts.
I suggest you encode some of the parts that work and finalize what you need to do to finish repairing them, I'll take care of the jitter part. -
Amazing work jmac698!
Cherbette could you post the processed video so we can see the results -
Nice work, jmac698.
Last edited by sanlyn; 21st Mar 2014 at 07:13.
-
What about Lp speed recordings you think this script would help ?
*** DIGITIZING VHS / ANALOG VIDEOS SINCE 2001**** GEAR: JVC HR-S7700MS, TOSHIBA V733EF AND MORE -
-
This video has a bit of what I would describe as a flicker to it as well...I was thinking "DeFlicker" might do the trick but I'm having a hard time finding a difference.
-
Do you guys have any advice as to which filter to correct the "brightness flicker"? I've been researching a few different filters but none seem to meet my needs here.
-
http://www.sendspace.com/file/qyh2ve
I think it's a bit better, tell me what you think.
Anyhow I'm sure I could do it perfectly but with the technique I'm using it's some manual work per scene. -
Ok,here's how to do it, it's a mess you just have to understand what your doing
Code:#cherbette part2 after dejitter processing AVISource("D:\project001a\sampleproblem5\cherbette.avi") src=last crop(200,50,50,100).pointresize(400,400) orig=last ScriptClip(""" global b=averageluma subtitle(string(b)) tweak(bright=140-b) b2=averageluma subtitle(string(b2),y=16) """) ScriptClip(src,""" b=orig.averageluma tweak(bright=140-b) #subtitle(string(b)) """, args="orig") MCTemporalDenoise(settings="low") QTGMC( Preset="Slow" , Sharpness=1.2, SLMode=1) selecteven
To adjust for another scene, find a spot that shouldn't be changing, show orig only, read off the number it says (pick any one - it will be changing), then use that number as the constant instead of 140.
It looks so much better mostly because, once the brightness is stabilized, the other filters can work better.
You need GRunT installed. -
-
Sorry to confuse you It's only used for examining the settings to use. I did say the script was a mess...
Btw, how to average all frames in a clip, pixel by pixel? -
I'm not sure I'm following you exactly. Where do I come up with the number to replace "140" for different scenes? Csamp or...?