# Interlacing issue and restoration on VHS capture.

1. Hi guys,

So on my captured VHS (captured using HuffYUV) i am getting a combing effect around certain edges.
Here is a screenshot to show what i mean.

How can i avoid or get rid of this without any loss of quality?

My setup is VCR->PanasonicES10->CaptureDevice->PC using AmarecTV 3.0
Capturing at 720x576 25FPS YUY2 (PAL)

Thanks.
2. VHS is a natively interlaced format, as was all analog SD TV. There are many ways you can convert it to progressive. If this is video from a camcorder or live TV (news, sports, etc.) the best deinterlacing is with QTGMC in AviSynth. But that has a fairly steep learning curve as AviSynth is a text script based video processing system. If your video was a movie shot on film you may be able restore the original progressive film frames with TFM, again in AviSynth. Many editing/conversion applications have deinterlacing options, most with mediocre results. You can try Handbrake's decomb filter with the double frame rate option (50 fps) for camcorder video, single frame rate (25 fps) for film sources.
3. There is a decomb filter on the ES10, but even though i have it enabled, it doesnt seem to do much.

So is my actual huffYUV avi file interlaced? the mediaInfo data for the file doesnt state interlaced or progressive.

The source i am using is a VHS tape copied from an old camcorder tape.
4. The AVI header doesn't have any way to indicate the video is interlaced. Some codecs can flag the video as interlaced internally (not huffyuv) and some programs know how to get at that information. Some programs will look through the frames form combing and then determine (sometimes wrongly) if the video is interlaced or progressive. If you post a short sample (a few seconds with motion, don't reencode it) I'll take a look and let you know exactly what you have.
5. Ok thanks, I think this should be alright, its only 4 seconds long due to the filesize of huffYUV.
I'm thinking it's interlaced.
6. Originally Posted by VSz
I'm thinking it's interlaced.
You're right - it's interlaced.
How can i avoid or get rid of this without any loss of quality?
You can't. Any reencoding to a lossy codec involves loss of quality. However, I'm assuming you want to work on the source a little bit so you'll be reencoding it anyway. If for DVD you'll probably want to keep the interlacing. If for some other final format you might want to deinterlace it, using a single rate (25fps) or double rate (50fps) deinterlacer. As jagabo already mentioned, for best results you'll want to use an AviSynth deinterlacer.
7. Originally Posted by VSz
Ok thanks, I think this should be alright, its only 4 seconds long due to the filesize of huffYUV.
I'm thinking it's interlaced.
As suggested by Jagabo above, a best quality de-interlace would probably come by using QTGMC in Avisynth. Bit of learning curve, if you don't already use Avisynth.

You might try the Yadif de-interlacer in Virtualdub......that is free, a bit simpler to use, and gives quite good results.

Running your clip through that - selecting top field first and double frame rate options - and then encoding with x.264, produces the attached file.

No other processing done..
8. Originally Posted by pippas
Running your clip through that - selecting top field first and double frame rate options - and then encoding with x.264, produces the attached file.
Will having a 50 FPS file not affect anything? such as audio sync and device compatibility.

I am wanting the best quality progressives for my master files for archiving, these files will be burned to blurays so i have about 25gb space per disc.
So basically i have interlaced lossless huffYUV at moment, is there a lossless way to deinterlace and keep the quality i currently have?

I have never used avisynth, is QTGMC better than Yadif?
9. Originally Posted by VSz
I have never used avisynth, is QTGMC better than Yadif?
QTGMC is better than yadif but in many cases yadif quality gives sufficiently decent quality and it works in real time (QTGMC is CPU demanding).
You may use ffmpeg instead Avisynth for deinterlacing (but QTGMC is not available in ffmpeg natively - you may use nnedi as QTGMC substitute).
10. so, like i said before, will deinterlacing at 50fps instead of 25fps have any detrimental/negative effects whatsoever to such things as device compatibility or audio sync? or would it be of benefit.

I think i'll try with QTGMC first, and if i cant use it, i'll try Yadif.

Speaking of QTGMC, is this guide still relevant? i ask because the posting is 6 years old.
QTGMC Deinterlacing Script (v3.32)
11. Originally Posted by VSz
Will having a 50 FPS file not affect anything? such as audio sync and device compatibility.
50 fps at 720x576 isn't Blu-ray compatible. But it is at 1280x720. So you could upscale to 720p for Blu-ray.

Originally Posted by VSz
I am wanting the best quality progressives for my master files for archiving
Your huffyuv files should be your archive. Any filtered and converted files are for watching.

Originally Posted by VSz
is there a lossless way to deinterlace and keep the quality i currently have?
Deinterlacing is always potentially destructive. There's simply no way to convert two half pictures (every other scan line) into two one or two full pictures perfectly. This is why you want to save your huffyuv AVI files as an archive. QTGMC is the best deinterlacer today, but in the future there may be even better deinterlacers. If you don't save your source files you won't be able to take advantage of them. The same is true of any other filtering you do on your videos.

Originally Posted by VSz
Yes. But with fuzzy video like yours the difference isn't huge. QTGMC adds a little noise reduction and edge smoothing. In the attached video Yadif was used on the left, QTGMC on the right (video brightened for better visibility):
12. Originally Posted by jagabo
50 fps at 720x576 isn't Blu-ray compatible. But it is at 1280x720. So you could upscale to 720p for Blu-ray.
I'm not burning it as bluray-video, just bluray-data. but it still doesnt answer my question on 50fps vs 25fps for audio sync etc.

Originally Posted by jagabo
The issue i have with this is filesize, the original huffYUV files are anywhere from 40-100gb each.

Originally Posted by jagabo
In the attached video Yadif was used on the left, QTGMC on the right (video brightened for better visibility):
Thanks for that comparison, its very helpful. So is that just the original file with nothing but brightness turned up?
They both look very similar, but i think i can see a slight improvement on the right side video (but that might just be my eyes).

I'm going to look into trying to use avisynth and QTGMC, it looks rather complex but i'm sure i'll figure it out.

Thanks for all the help guys.
13. Originally Posted by VSz
... but it still doesnt answer my question on 50fps vs 25fps for audio sync etc.
Doubling the fame rate does just that. It does not affect the run time or audio sync. A 50fps clip will display any motion more smoothly than a 25fps clip...

Your original interlaced video will displaying 50 fields per seconds - so 50 separate images.

Doubling the frame rate as part of the de-interlacing process will help maintain that original 50 image per second 'smoothness'
14. Ah i see now, thank you for explaining that.
15. Originally Posted by VSz
it still doesnt answer my question on 50fps vs 25fps for audio sync etc.
There will be no problem with audio sync. The number of frames is doubled but the rate at which they play back is doubled too. So there's no change in the running time. Some older devices might not be able to keep up with 50 fps though.

Originally Posted by VSz
is that just the original file with nothing but brightness turned up?
I brightened the video then stacked Yadif and QTGMC deinterlaced videos side by side. I also reduced some flicker. One field was lighter than the other at the top of the frame. I darkened the top of the bright field to more closely match the brightness of the darker field.
16. Originally Posted by jagabo
I also reduced some flicker. One field was lighter than the other at the top of the frame. I darkened the top of the bright field to more closely match the brightness of the darker field.
How did you achieve this, i've never attempted anything like that before.
17. Originally Posted by VSz
Originally Posted by jagabo
I also reduced some flicker. One field was lighter than the other at the top of the frame. I darkened the top of the bright field to more closely match the brightness of the darker field.
How did you achieve this, i've never attempted anything like that before.
I made an image with a gradient from black at the bottom to a very dark grey at the top. I then subtracted that from the field that was too bright at the top. The actual code looked like this:

Code:
AviSource("sample.avi")

AssumeTFF()

SeparateFields()
evn = SelectEven().Overlay(grad, mode="subtract") # subtract the gradient from the even fields
odd = SelectOdd()
Interleave(evn,odd)
Weave()

QTGMC() # or Yadif(mode=1)
The image looked like:

[Attachment 39699 - Click to enlarge]

The result wasn't perfect but it was a little better.
18. Ok thanks for that jagabo, i will have a go with avisynth and try this out later tonight.
So do i just run the avisynth scripts through VirtualDub? or do you some other method?
19. I use VirtualDub to view the result of my AviSynth scripts. When I encode I use the x264 command line encoder via a batch file. I just drag/drop the AVS script onto the BAT file. Sample batch file:

Code:
start /b /low x264.exe --preset=slow --crf=18 --sar=1:1 --colormatrix=bt709 --output %1.mkv %1
@pause >nul
20. So i installed avisynth v2.6 & QTGMC and all the relative plugins involved and tried to run the script, but i got the following error.
AVISynth open failure:
AVISource: couldn't locate a decompressor for fourcc HFYU
(script.avs, line 1)
I'm also getting
Unable to open file script.avs
when trying to open it in VirtualDub 1.10.4
21. The first error indicates AviSynth couldn't find a decoder for huffyuv. What source filter are you using in AviSynth? AviSource() as in my earlier example? In that case you need a VFW decoder for huffyuv.

Be sure you have all 32 bit components, or all 64 bit components. AviSynth, all AviSynth filters, VirtualDub, huffyuv, etc. In fact, just forget 64 bit and use all 32 bit components. Many components you'll be using aren't available in 64 bit versions, or the 64 bit versions have more bugs.

By the way, QTGMC is one of the hardest filters to get set up for a beginner. Because it requires so many third party filters.
22. Originally Posted by jagabo
What source filter are you using in AviSynth? AviSource() as in my earlier example? In that case you need a VFW decoder for huffyuv.
Yes i am using AVISource. I have huffyuv codec installed but it still says no decompressor. huffyuv isnt even showing in virtualdub compression list.

Originally Posted by jagabo
Be sure you have all 32 bit components
Yes, all the components i installed were 32bit.
23. Ok so i fixed the huffyuv problem (i'm working on a 64 bit windows 8.1 machine)
I had to install it using the rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 0 c:\path\to\huffyuv.inf method.

But now i've encountered another issue.
mt_makediff: unsupported colorspace. masktools only support planar YUV colorspaces (YV12,YV16,YV24).
is this because the huffyuv video has an RGB color space?

@jagabo could you tell me what brightness settings you used on that YvQ.mkv sample. I tried a few and none seem to look as nice as what you did. Did you use Tweak() ?
24. Originally Posted by VSz
mt_makediff: unsupported colorspace. masktools only support planar YUV colorspaces (YV12,YV16,YV24).
is this because the huffyuv video has an RGB color space?
You probably needed
Code:
 ConvertToYV12(interlaced=true)
before the QTGMC() line.

Originally Posted by VSz
could you tell me what brightness settings you used on that YvQ.mkv sample. I tried a few and none seem to look as nice as what you did. Did you use Tweak() ?
I don't have that script anymore but I think it was something like:
Code:
ColorYUV(gain_y=200, off_y=-68, gamma_y=150)
If you want more saturated colors use this instead:
Code:
ColorYUV(gain_y=200, off_y=-68, gamma_y=150, cont_u=100, cont_v=400)
The colors are still way off and full of VHS chroma noise.
25. Originally Posted by jagabo
The colors are still way off and full of VHS chroma noise.
Would you say this was all correctable using avisynth and ColorYUV/Tweak?
It seems quite a time consuming job with it having no live visual preview (except for reloading the avs script into vdub everytime).
26. Originally Posted by VSz
It seems quite a time consuming job with it having no live visual preview (except for reloading the avs script into vdub everytime).
Try opening your Avisynth scripts with this: https://www.videohelp.com/software/AvsP Not a 'true' GUI, but pretty useful - I certainly find it easier than checking each script edit by opening each change in Vdub....
27. Thanks for that pippas, i will definitely take a look.
28. Originally Posted by VSz
Originally Posted by jagabo
The colors are still way off and full of VHS chroma noise.
Would you say this was all correctable using avisynth and ColorYUV/Tweak?
It seems quite a time consuming job with it having no live visual preview (except for reloading the avs script into vdub everytime).
It can be quite hard to correct colors in AviSynth. You will need a lot more than just ColorYUV and Tweak. Some related filters are RGBAdjust and Levels. You may need to build masks for particular color ranges, brightness ranges, etc. and Overlay modified colors only in those areas.

There are many noise reduction filters: http://avisynth.nl/index.php/External_filters#Denoisers

You can apply different noise reduction to the luma and chroma:

Code:
luma = NoiseReductionA()
chroma = NoiseReductionB()
MergeChroma(luma, chroma)
Using the Animate() filter can be helpful. It lets you change settings over a number of frames.

Code:
function AnimateSaturation(clip c, float val)
{
Tweak(c, sat=val) # change the saturation
Subtitle(string(val)) # show the value used
}

AviSource("sample.avi")
ColorYUV(gain_y=200, off_y=-68, gamma_y=150) # fixed brightness,contrast, gamma change
Animate(0,100, "AnimateSaturation", last,1.0, last,6.0) # animate saturation change
This example increases the saturation from 1.0 to 6.0 over the first 100 frames. You can scrub through the video to find what saturation looks best to you.

But I don't think any program is going to get you great colors with this source.

One hint for VirtualDub: pressing F2 will reload the script at the current frame.
29. You do need to understand that you are trying to fix a problem that doesn't actually exist. Therefore, my recommendation is to do nothing.

The reason you see that combing effect is that you have captured a single frame of video that is made up of two adjacent fields. The odd fields are from one moment in time, and the even fields from another moment in time. When you display both of them at the same moment in time in a freeze frame, you get combing because things have moved between the moment in time when the even field was captured and the next moment in time when the odd field was captured. However, when you actually play the video file, you won't see this because your TV or video player handles everything for you (and on a display that can natively display interlaced video, it will look perfect).

So, go ahead and deinterlace if you want to do that, but be aware that you don't really need to do that, and that you will degrade your video by deinterlacing it, and that degradation can never be undone. Of course if you do the deinterlacing using QTGMC, that degradation will be less than if you use other deinterlacers, but it will still be degraded.
30. Originally Posted by johnmeyer
when you actually play the video file, you won't see this because your TV or video player handles everything for you
Of course, this assumes you handle the video correctly before it gets to the player or TV. Don't do anything that mingles the two fields and encode interlaced.

Statistics