Go Back    Forum > Digital Video > Video Project Help > Restore, Filter, Improve Quality

Reply
 
LinkBack Thread Tools
  #1  
03-12-2018, 05:10 AM
umetnic umetnic is offline
Free Member
 
Join Date: Jan 2018
Posts: 2
Thanked 0 Times in 0 Posts
Hello!

I too got a task to restore 50 or so VHS tapes with precious family memories.
They are mostly in fairly bad shape to begin with and capturing them with cheap old VCR and even cheaper easycap device doesn't do them any good either.

However, this is what I have to work with and in last few months I got my workflow process down to this;

1. Capture with AmaRecTV 2.31 with lossless UtVideo (YUV422 BT.601 VCM) codec. (Virtualdub never gave me good enough AV sync, no matter what setting I tried...)
2. Export sound to .wav and remove hiss/hum with Goldwave v6.31. (I use clipboard sample from the beginning or end of the tape)
3. AviSynth Script with help of AvsPmod 2.51 (Trim to separate clips, Crop to remove black borders and dirty tape head part at the bottom, Deinterlace with QTGMC 3.357 script to improve footage and convert to progressive, FadeIn/Out)

Code:
SetMemoryMax(4000)  # I have Win10 x64 and 16GB and these settings works best for me.
SetMtMode(5,4) # more at http://avisynth.nl/index.php/QTGMC#SetMTMode_X  

#video = AVISource("plates.avi", audio=false) # only video, I am adding audio separately below
#audio = WAVSource("plates.wav") # Matching audio processed separately in goldwave. I used VirtualDub to export wav file.
#AudioDub(video, audio) #'joining' video and audio together, before processing them further.

AVISource("plates.avi", audio=true) # reference line for testing purposes without cleaned audio. Uncomment this and comment out above three lines if U want to use original audio.

ConvertToYV12(interlaced=true) #U need to convert to YV12 Colorspace for QTGMC to work

AssumeTFF() #If video is switching back and forward during frame by frame preview, change this to BFF

#Trim(first frame of the clip,last frame of the clip) # I use this to trim only the wanted clip from the captured footage

Crop(4, 8,-16,-8) #left, top, right, bottom

SetMtMode(2) # switch to mode 2 for QTGMC

QTGMC(Preset="Slower",tr2=3,EdiThreads=4,Sharpness=1.0,SLMode=1) # I get 12-16FPS on i5 CPU with these settings. I picked them up from a forum. Not sure if they are the best, but I guess result looks kinda better than source :)

FadeIn(20) # Number means through how many frames
FadeOut(10) # Number means through how many frames
4. Encode to x264 encapsulated in mkv format (where I can force viewing aspect ratio with help of MKVToolNix 21.0.0, so VLC shows it correctly) with MeGUI 2828. I use a constant quality set to 24 with medium speed, which yields acceptable size and not much quality loss (at least to my eyes..). (MeGUI Encoder settings; program --output-depth 8 --crf 24 --qpmax 69 --output "output" "input" )

The final result will mostly be played on PC and I plan to delete lossless captures and keep only these mkv files for archival purposes.

The challenge I am facing ATM is 'moire effect' (not sure how to call it, but it reminds me at moire from the old days of CRT monitors =)) If You check source.avi and encode.mkv, You will notice it appearing over the stack of plates (plates.mkv) or skirt of a girl (skirt.mkv). Source AVIs doesn't have it. Plates or dress don't flicker at all.

I tested different QTGMC presets with some other random settings from QTGMC manual and I also tried different x264 encoding presets, but this moire just doesn't go away.

I suspect it is introduced by QTGMC, but I really don't know anymore how to fix this, neither if it is fixable at all? My wife says 'leave it' but after all the time spent on this, learning the ropes, it really annoys me.

Any insights what is causing this or how to fix it would be greatly appreciated!


Attached Files
File Type: avi plates.avi (81.75 MB, 16 downloads)
File Type: avs plates.avs (1.4 KB, 2 downloads)
File Type: mp4 plates.mp4 (2.64 MB, 19 downloads)
File Type: mp4 skirt.mp4 (3.07 MB, 11 downloads)
File Type: avi skirt.avi (77.02 MB, 16 downloads)

Last edited by umetnic; 03-12-2018 at 05:49 AM.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
03-18-2018, 06:15 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,307 Times in 982 Posts
Quote:
Originally Posted by umetnic View Post
I too got a task to restore 50 or so VHS tapes with precious family memories.
They are mostly in fairly bad shape to begin with and capturing them with cheap old VCR and even cheaper easycap device doesn't do them any good either.
Your point is appreciated, but let's face it: you're making the project much more difficult and time consuming than it should be.

Quote:
Originally Posted by umetnic View Post
1. Capture with AmaRecTV 2.31 with lossless UtVideo (YUV422 BT.601 VCM) codec. (Virtualdub never gave me good enough AV sync, no matter what setting I tried...)
AmarecTV will do the job. I'm afraid I have no answer for you with Virtualdub. I've used it to capture with Win98, Win2K, and XP with four graphics cards and and several PC's, and never had a sync problem. I guess if I'd had to fix it I would have a solution, but it's never happened. Some system setups just don't seem to make nice with certain programs. No one has determined why.

Quote:
Originally Posted by umetnic View Post
Crop to remove black borders and dirty tape head part at the bottom
Most people would crop off bad borders, but they replace them with clean new ones. Many newcomers think they're improving something by changing the frame size (you'll get black borders on playback anyway, because your monitor will put them there). Unfortunately your playback aspect ratio is wrong, and if encoded for 4:3 the image will be slightly distorted. Your source video VHS plays at 1.3333:1, but the encode plays at a more narrow (squished) 1.25:1, which is the frame aspect ratio of your script's output and is a substandard frame size. Is that what you wanted?

Quote:
Originally Posted by umetnic View Post
Deinterlace with QTGMC 3.357 script to improve footage and convert to progressive, FadeIn/Out)
Deinterlacing doesn't improve anything, in fact it destroys some factors, distorts others, and entails a quality loss, the degree depending on the method used. QTGMC is the cleanest method these days. But the problem is due to line twitter and aliasing, to the original camera's shutter design, and to vcr sharpening during playback, not to interlacing. Note also that your script's output frame size isn't mod-8 in all dimensions -- a width of 700 isn't evenly divisible by 8, so you might at least give your players and encoder a decent break with a mod-8 or mod-16 dimension. Most encoders work with 8-pixel blocks. If you ignore the standards, you get odd results.

Quote:
Originally Posted by umetnic View Post
I suspect it is introduced by QTGMC, but I really don't know anymore how to fix this
The bad twitter is inherent in the tape, which was designed for a different technology, and already visible to a lesser extent in the capture. Cheap VCR's don't help. Sadly, digital video and LCD's don't handle motion well, so this kind of moire and stairstepping happens quite often with digital conversion, even with a better VCR. Making the video somewhat less sharp helps, which is what the scripts do that I posted below. The disturbances can't be fixed entirely, but they can be calmed somewhat.

I made extensive notes in the script for the skirt.avi sample, so I'll post that first. Twitter and aliasing aren't the only faults, as there are some bad dropouts and ripples. Red contrast is too wide for the video to handle, so the girl's face and details get wiped out under the red lights. I included code to work with unsafe video levels and other such problems. In the plates.avi sample, fixing mixed color sources and bad clipping during the capture is possible only to a slight degree.

On top of that I'm stuck working with a Dell laptop temporarily. Dell makes the worst laptop screens in the world, so color correction and inspecting for proper nosie reduction is very limited for the time being. Laptops are a disaster checking for noise and color correction is limited. Laptops are disastrous for video work anyway, but this will have to do until some home reconstruction in finished. Meanwhile this Dell doesn't have a/v muxing softare, so the attached samples are m2v encoded with the HCenc encoder and no audio.

The script I used for skirts.avi:
Code:
vid=AviSource("E:\forum\faq\umetnic\skirt.avi")
aud=vid        #<- save AVi audio for later, see end of script

### --- work with video portion of "vid" input ---###
vid
ColorYUV(cont_v=-125)      # <--- fix illegal v-channel (red) chroma contrast.
Tweak(cont=0.95,sat=1.4,dither=true,coring=false)    # <--- lower contrast, restore overall saturation.
Levels(16,1.0,255,16,235,dither=true,coring=false)   # <--- maintain safe y=16-235 luma levels.

ConvertToYV12(interlaced=true)
AssumeTFF()
QTGMC(Preset="slow",tr2=3,Sharpness=0.7,border=true)
vInverse2()                                          # <--- tweak to calm excessive combing. 
DeHalo_Alpha()                                       # <--- calm bright edge sharpening halos.

### --- Upscale/downscale & twitter smoothing, low pass filter, & anti-aliassing ---###
ConvertToYUY2(interlaced=false)
nnedi3_rpow2(opt=2,rfactor=2,cshift="spline36resize").Blur(0.3,0.4)
SPline36Resize(720,288)
SPline36Resize(720,576)
Santiag(2,2)

### --- chroma denoise, color/saturation corrections with VDub filters ---###
ConvertToRGB32(interlaced=false)
LoadVirtualDubPlugin("E:\VirtualDub\plugins\ccd.vdf","CamcorderColorDenoise",1)
LoadVirtualDubPlugin("E:\VirtualDub\plugins\ColorMill.vdf","ColorMill",1)
CamcorderColorDenoise(30,1)
ColorMill(25700, 28260, 25700, 25685, 25700, 25700, 27499, 25707, 25700, 25700, 25700, 25700, 25700, 1124, 2052)

### --- interpolate new images for some frames with bad dropouts ---###
### ---   (note that frame numbers are for deinterlaced frames)  ---###
ConvertToYV12(interlaced=false)
ReplaceFramesMC(55,5)      # <--- original interlaced frames 27-28-29, even and odd fields
ReplaceFramesMC(131,1)     # <--- bottom field in original interlaced frame 65

SmoothUV()
LimitedSharpenFaster(strength=75,edgemode=2)
Crop(6, 0,-14,-10)     # <- Crop off noisy and uneven borders, leave core image intact
AddBorders(10,4,10,6)  # <- restore original frame size

### --- restore interlace ---###
AssumeTFF().SeparateFields().SelectEvery(4,0,3).Weave()

### --- restore audio for bad frames fixed by ReplaceFramesMC ---###
AudioDub(last,aud)

return last
### --- save in VirtualDub as Lagarith lossless YV12 --- ###
Somewhat less complicated script for plates.avi:
Code:
AviSource("drive:\path\to\plates.avi")
cOLORyuv(OFF_Y=-8,cont_u=-25,off_u=-2,cont_v=-25,off_v=-2)
Levels(20,1.2,255,16,240,dither=true,coring=false)
ConvertToYV12(interlaced=true)
AssumeTFF()
QTGMC(Preset="slow",tr2=3,Sharpness=0.7,border=true)
vInverse2()
DeHalo_Alpha()

ConvertToYUY2(interlaced=false)
nnedi3_rpow2(opt=2,rfactor=2,cshift="spline36resize").Blur(0.3,0.3)
SPline36Resize(720,288)
SPline36Resize(720,576)
### --- for progressive square-pixel video, disable the --------###
### --- statement above this line and enable the line below. ---###
### SPline36Resize(768,height)
Santiag(2,2)

ConvertToRGB32(interlaced=false)
RGBadjust(rg=0.7,rb=0.9,gb=0.9)
LoadVirtualDubPlugin("Drive:\VirtualDub\plugins\ccd.vdf","CamcorderColorDenoise",1)
CamcorderColorDenoise(30,1)

ConvertToYV12(interlaced=false)
SmoothUV()
LimitedSharpenFaster(strength=75,edgemode=2)
FadeIn(20) 
FadeOut(10) 
Crop(4, 8,-12,-8)    # <- Crop off noisy and uneven borders, leave core image intact
AddBorders(8,8,8,8)  # <- restore original frame size

### --- for progressive square-pixel video, disable the next line ---###
AssumeTFF().SeparateFields().SelectEvery(4,0,3).Weave()

return last
#### --- save in VirtualDub as Lagarith lossless YV12 --- ###
In addition to the two m2v's, I'm attaching the lossless output of the script for the skirt.avi sample, which you can try with your own encoder. The attached skirt_01Ai.avi file is lossless YV12 using the Lagarith lossless codec. VLC can't play YV12 Lagarith well, but Media Player Classic and MPC-BE have their own Lagarith decoder. You should install Lagarith anyway, since your own encoders will need it and it's used everywhere for intermediate working files (huffyuv can't compress YV12). I've included the Lagarith automatic setup .zip file for 32- and 64-bit, or you can consult Lagarith's download site (https://lags.leetcode.net/codec.html).


Attached Files
File Type: m2v skirt_DVD.m2v (7.14 MB, 7 downloads)
File Type: m2v plates_DVD.m2v (7.29 MB, 5 downloads)
File Type: avi skirt_01Ai.avi (51.41 MB, 9 downloads)
File Type: zip LagarithSetup_1327.zip (409.1 KB, 2 downloads)
Reply With Quote
  #3  
03-18-2018, 06:43 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,307 Times in 982 Posts
[EDIT]
Oops! Spotted a script error, one of those infamous typos. In my previous post you'll see this code in the script for the plates.avi sample:

Code:
ConvertToYUY2(interlaced=false)
nnedi3_rpow2(opt=2,rfactor=2,cshift="spline36resize").Blur(0.3,0.3)
SPline36Resize(720,288)
SPline36Resize(720,576)
### --- for progressive square-pixel video, disable the --------###
### --- statement above this line and enable the line below. ---###
### SPline36Resize(768,height)
Santiag(2,2)
I guess I should have waited for that third cup of coffee before posting. the resize of (768,height) will give you the wrong height. The corrected resize is below:

Code:
ConvertToYUY2(interlaced=false)
nnedi3_rpow2(opt=2,rfactor=2,cshift="spline36resize").Blur(0.3,0.3)
SPline36Resize(720,288)
SPline36Resize(720,576)
### --- for progressive square-pixel video, disable the --------###
### --- statement above this line and enable the line below. ---###
### SPline36Resize(768,576)
Santiag(2,2)
My bad.
Reply With Quote
  #4  
03-21-2018, 02:06 AM
umetnic umetnic is offline
Free Member
 
Join Date: Jan 2018
Posts: 2
Thanked 0 Times in 0 Posts
WOW, @Sanlyn! I could Hug U right now!
I read many of your quality replies on this forum but still didn't dare to hope I would also get one.
Please allow a few days to comprehend and test/apply everything You wrote and I'll come back with my new findings/results.
Reply With Quote
  #5  
03-21-2018, 06:29 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,307 Times in 982 Posts
Gosh. Thank you, but with a little experimentation we might get slightly better results. This time I'm posting a 640x480 progressive square-pixel version as 50fps mp4. I still think MPEG2 looks a bit cleaner, but it can't be posted on the internet and can't be encoded as square-pixel. Resizing both width and height for square pixel does have a price in the moire pattern, but it still looks slightly cleaner to me than the earlier version.

The script below is a little different. Note that ReplaceFramesMC works OK to repair some bad dropouts, but the frames it replaces have no audio, so you get choppy audio at the repair points. The "aud" variable in the script below saves the original audio at 50fps after running QTGMC, then restores it near the end of the script. If you save the audio at an earlier point as in the earlier script for interlaced video, the earlier audio runs at the 25fps frame rate.


Code:
Import("drive:\path\to\Avisynth plugins\RemoveDirtMC,avs")  #<-- change path for your system.

AviSource("E:\forum\faq\umetnic\skirt.avi")
ColorYUV(cont_v=-125)
Tweak(cont=0.95,sat=1.4,dither=true,coring=false)
Levels(16,1.0,255,16,235,dither=true,coring=false)

ConvertToYV12(interlaced=true)
AssumeTFF()
QTGMC(Preset="slow",tr2=3,Sharpness=0.7,SLmode=2,border=true)
vInverse2()
vid=last
aud=vid           #<- save 50fps AVi audio for later, see near end of script

vid
DeHalo_Alpha()
ConvertToYUY2(interlaced=false)
nnedi3_rpow2(opt=2,rfactor=2,cshift="spline36resize").Blur(0.5,0.5).Blur(0.4,0.4).Blur(0.4,0.4)
Santiag(2,2)
SPline36Resize(640,288).Blur(0.3,0.3)
SPline36Resize(width,480)

ConvertToRGB32(interlaced=false)
LoadVirtualDubPlugin("E:\VirtualDub\plugins\ccd.vdf","CamcorderColorDenoise",1)
LoadVirtualDubPlugin("E:\VirtualDub\plugins\ColorMill.vdf","ColorMill",1)
CamcorderColorDenoise(30,1)
ColorMill(25700, 28260, 25700, 25685, 25700, 25700, 27499, 25707, 25700, 25700, 25700, 25700, 25700, 1124, 2052)

ConvertToYV12(interlaced=false)
ReplaceFramesMC(131,1)
ReplaceFramesMC(55,5)

RemoveDirtMC(40,false)
SmoothUV()
LimitedSharpenFaster(strength=75,edgemode=2)
Crop(6, 0,-14,-10)    
AddBorders(10,4,10,6)  # <- restore 640x480 frame size

### --- restore 50fps audio for bad frames fixed by ReplaceFrramesMC ---###
vid2=last
vid3=AudioDub(vid2,aud)
return vid3
#### --- save in VirtualDub as Lagarith lossless YV12 --- ###
I'm attaching a copy of the version of RemoveDirtMC that I used. There are several versions, so it's posted as an .avs that you should import explicitly with the import() function.


Attached Files
File Type: mp4 skirt_03RD_50p.mp4 (4.87 MB, 9 downloads)
File Type: avs RemoveDirtMC.avs (2.5 KB, 4 downloads)
Reply With Quote
The following users thank sanlyn for this useful post: wimvs (03-21-2018)
Reply




Tags
moire, vhs restoration, vhs restore filter

Similar Threads
Thread Thread Starter Forum Replies Last Post
Horizontal black lines made worse by QTGMC? koberulz Restore, Filter, Improve Quality 15 10-22-2017 08:54 AM
Horizontal lines/scanlines in captures? (ATI 600 USB) Turok81 Capture, Record, Transfer 8 11-27-2016 08:25 PM
Severe horizontal red/green lines during parts of video Towncivilian Restore, Filter, Improve Quality 1 09-04-2016 03:04 AM
Panasonic AG-W1 produces scrambled picture with no color, worth repair? autephex Video Hardware Repair 6 11-13-2014 07:06 AM
Remove extra lines (empty lines) from copied/pasted text with Notepad++ kpmedia Computers 1 10-07-2011 05:32 PM

Thread Tools



 
All times are GMT -5. The time now is 10:31 PM