# Help to improve visual quality of vhs

1. Hi

This is my first time trying to convert a vhs capture to a MKV/x264. I have been doing many test (way to many) with avisynth to get the best result. If anybody could give me some advise on what to use it would be very apreciated. The vhs is commercial, captured with lossless codec (Huffyuv, makes the sample a bit big, sorry about that).

I don't know much avisynth, I am barely an amator, that's mainly the problem, because I don't know what I am doing. I've tried different approch but this script seems to give me similar or the better result so far. But I don't like the color they seem wrong to me, and I can't manage to fix them. (I am sure there is many things to fix in this video, that I don't see).

SetMemoryMax(512)
SetMTMode(5,3)
FFVideoSource(source="C:\Users\Video 1.mkv")
SetMTMode(2,0)
ColorYUV(gamma_y=-12, off_y=-6, off_u=1,off_v=-2)
AssumeTFF()
converttoYV12(interlaced=true)
QTGMC( Preset="slow", SourceMatch=3, Lossless=2 )
SelectEven()
Crop(10,0,-10,-8)

Any advise are welcome, on how to approch this video. Thank you

Here's the link for the sample : https://1fichier.com/?tc67dodpjohjs4usg2ik

It's 275 mo for 40 sec, I know it's big... but I convert with x264 Quality: 18 so it give a very small result.
2. Is this an unaltered sample of your original capture? What's with the mkv container?

Can we ask some questions first? Why are you throwing away 50% of your video with SelectEven()? Are you keeping the half that you like and throwing away the half that you don't like? And before you go any further and really screw it up even more, are you aware that that the movie is film sourced and is not interlaced? Have you wondered why the tops and side borders of the frames are warped toward the left? What player are you using? What capture device? Have you ever heard of a line level tbc?
3. Yes it is an unalterned sample, MKV was just a very simple way to cut it. My avicutter kept crashing...

Selecteven() is just to keep the original frame rate. if you are suggesting that 60ftp is better than I'll take away the selecteven()...

Like I say I am a nob regarding avisynth or video convertion, I am in a process of learning.

Never heard of level tbc

Mediainfo tell me it's interlaced, and it looked to me interlaced. It'S good to know if am wrong, any suggestion on what to do ?

CApture was made with virtualdub codec Huffyuv + wintv7. (I am sure there is better material for capture, not worth to invested for such vhs)

Player is : captured with JVC HR-A592U (might be shity but that's what I have..)

I want to play it on HDTV, the tv doesn'T deinterlaced....

If that can help

General
Complete name : C:\Users\Video 1.avi
Format : AVI
Format/Info : Audio Video Interleave
Format profile : OpenDML
File size : 35,0 Gio
Duration : 1h 30mn
Overall bit rate : 55,6 Mb/s

Video
ID : 0
Format : HuffYUV
Format version : Version 2
Codec ID : HFYU
Duration : 1h 30mn
Bit rate : 54,0 Mb/s
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 3/2
Frame rate : 29,970 Im/s
Standard : NTSC
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Scan type : Entrelacé
Bits/(Pixel*Frame) : 5.214
Stream size : 34,0 Gio (97%)

Audio
ID : 1
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 1h 30mn
Bit rate mode : Constant
Bit rate : 1 536 Kbps
Channel(s) : 2 canaux
Sampling rate : 48,0 KHz
Bit depth : 16 bits
Stream size : 990 Mio (3%)
Alignment : Alignée sur les interleaves
Interleave, duration : 10 ms (0,30 image vidéo)
Interleave, preload duration : 159 ms
4. The clip is a film source. You should use TFM().TDecimate() rather than QTGMC(). That will give you the original 23.976 fps film frames.
5. Thank you for the input Jagabo, it's very welcome.

I will do that.

If anybody has any other advise on how to process with this video, I'll be grateful.
6. Your video has pretty bad oversharpening halos. Removing the halos in software will damaging the picture quite a bit. If your VHS deck has a sharpness control -- turn it down before capturing. If not, consider finding a deck which doesn't sharpen as much. The analog sharpeners in VHS decks are terrible. If you can get caps without them you can sharpen much better in software.

Automatic gain somewhere in your record/playback/capture chain is causing levels to bounce up and down, especially at scene changes. Turn off any automatic gain controls you may have.

The black level in your ColorYUV() adjustments is about right but the white levels are pretty low. It's possible that all the shots were supposed to be like that (not every shot is supposed to have full black and full white) but probably not. If you crank up the gain to get brighter whites you'll have to pull the offset down a little more. I don't think the chroma shifts helped at all. I thought the white balance was better without them.
7. Seems there is some confusion somewhere. Let's see if I understand you:

Your MediaInfo report says that your capture "Video 1.avi" is lossless YUY2 Huffyuv Avi format. Yet your sample avisynth script is using FFMS2 to open an mkv. What happened to the original AVI?

Originally Posted by Altruo
MKV was just a very simple way to cut it. My avicutter kept crashing...
What Avicutter? That mkv business is looks complicated. What kind of AVI cutter are you talking about? Lossless avi is not an encoded format, it can be cut in any editor including Virtualdub. Mkv is a container that was never designed for editing. What editor did you use that was crashing?

Lossless Avi is opened directly in Avisynth with the AviSource() function, and directly in VirtualDub by simply openig the AVI file with VirtualDub's "File" menu. There's no need to go into FFMS2 or mkv with losssless huffyuv AVI.

Originally Posted by Altruo
Selecteven() is just to keep the original frame rate. if you are suggesting that 60ftp is better than I'll take away the selecteven()...
Not suggesting that. If you had normally interlaced video at 29.97 fps, then when deinterlaced it wouldn't be 60p, it would be 59.94p. But interlaced video should remain interlaced. Deinterlacing always costs, even if it has to be done for filtering or other repair. The process is not free of quality issues. If you have to deinterlace to perform some sort of processing, it can be reinterlaced easily enough in Avisynth. Throwing away every other frame with SelectEven() discards 50% of your temporal resolution; motion will not be as smooth, especially during fast action and camera pans.

But as it is, this video isn't interlaced. This brings me to your next comment....

Originally Posted by Altruo
Mediainfo tell me it's interlaced, and it looked to me interlaced. It'S good to know if am wrong, any suggestion on what to do ?
It doesn't look interlaced to me. If you open it in VirtualDub or any editor and play it one frame at a time, you'll see that some frames are progressive and some frames look interlaced. It was encoded, broadcast, and captured as interlaced, but the content itself is hard-telecined with 3:2 pulldown. For every group of 5 frames, three frames are progressive and two frames appear to be interlaced. Because of the nature of 3:2 telecine, using a deinterlacer means you'll get groups of duplicate frames and poor motion rendering.

To remove telecine and restore the original progressive film speed, use inverse telecine. The Avisynth filter is TIVTC. As jagabo mentioned earlier, for the common form of telecine used in this video the code would be:
Code:
TFM()
TDecimate()
With this movie the result would be progressive NTSC video at 23.976 fps.

Originally Posted by Altruo
I want to play it on HDTV, the tv doesn'T deinterlaced....
Oh, I see. You have one of those smart TV's that isn't very smart. Actually your TV does deinterlace and it removes telecine, too -- it displays cable HDTV, DVD's, and 1080i BluRay normally, and all of those formats are either interlaced or telecined. I think what you mean is that your TV doesn't normally process interlaced or telecined video from a USB stick or other storage device. But TV's are not programmed to play from those devices the same way a set top player or PC media player would handle it. Forget about smart TV and think of it as not-very-smart TV.

Originally Posted by Altruo
Never heard of level tbc
It's not "level tbc", it's "line level tbc", or just "line tbc" -- an electronic time base corrector that corrects scanline timing errors during playback. Every frame of your NTSC capture has 480 horizontal scanlines. Each original scanline is output one line at a time in a continuous stream from your VCR into your capture device. But with most analog devices the scanlines don't appear at exact intervals -- that is, some scanlines arrive a few microseconds earlier or later than others. The output rate is not exact or uniform. But digital capture devices expect exact timing and are not designed to correct timing errors. During capture those timing errors take on a variety of distorted forms.

Look at the frame below, taken from your sample:

Can you see how the picture is warped toward the left at the top of the frame (look at the side borders)? Scanlines at the top of the frame are arriving later than scanlines at the bottom. And because of very tiny differences in scanline timing, the image will also look relatively soft compared to an image where a tbc exactly corrects the timing for every single scanline that defines an edge or shape in the image. Also visible are some annoying mistracking "ripples" along the bottom of the frame, just above the head-switching noise.

These timing errors can't be corrected in software. They can be fixed only with a line-level tbc during initial capture. if you can't get a VCR with built-in line tbc, get a recommended used legacy DVD recorder as a pass-thru device between your VCR and your capture chain. The recommended models are Panasonic DMR=ES10 or DMR-ES15. Most DVD recorders can't be used for tbc pas-thru, and many that can are uselessly puny. https://forum.videohelp.com/threads/319420-Who-uses-a-DVD-recorder-as-a-line-TBC-and-what-do-you-use

Originally Posted by Altruo
CApture was made with virtualdub codec Huffyuv + wintv7. (I am sure there is better material for capture, not worth to invested for such vhs)
Most people would use VirtualDub or AmerecTV for lossless capture, both of which are free. I agree with jagabo, I think your WinTV is doing more harm than good.
8. Thank you very much, both of you for those very detail explanation. Thank you Lmotlow, you gave me some good seedback, I actualy have a panasonic recorder somewhere in my box, I look at the model, but I doubt that I can use it as a pass-thru because of the DRM protection on the VHS. Anyway both of you have been very generous of your time. I'll look at my options and see what I can do...
9. If your Hauppauge device is overriding or ignoring copy protection, it will ignore copy protection through a pass-thru device. The pass-thru isn't used to record. You connect your VCR to the pass-thru's input, then connect the pass-thru's output to your capture setup. You don't record with the pass-thru. the source signal simply "plays through" the recorder and you make use of the recorder's tbc circuit for your capture. On the other hand,m uif your pass-thru unit visible "reacts" to the copy protection with fading and luminance pumping or so forth, you'll have to search for an external tbc unit or get a VCR that has a line tbc built-in (expensive, and finding one that still works is another problem).

To repeat: not all DVD recorders can be used for pass-thru. Those that work at all might not be powerful enough to fix your geometry problem.

Meanwhile I've had my own qualms with standard definition and PVR's. They aren't too bad if you can spend the time to clean up their shortcomings in Avisynth. It's a pain in the neck. The attached sample has some cleanup applied, for what it's worth. It uses the Avisynth FixVHSoversharp plugin, but it's only partially effective. Here is the script I used:

Code:
Avisource("drive:\path\to\Video 1.avi")

### --- inverse telecine ---
TFM()
TDecimate()

FixVHSOversharp(20,16,12)
FixVHSOversharp(20,8,4)
FixVHSOversharpL(20,12,8)

ConvertToYV24(interlaced=false)
Tweak(bright=-12,cont=1.3,dither=true,coring=false)
Levels(16,0.95,255,16,245,dither=true,coring=false)

ConvertToYV12(interlaced=false)
### ---Replace horizontal dropout in frame 39 with new frame ---
ReplaceFramesMC(39,1)
MergeChroma(awarpsharp2(depth=20).aWarpSharp2(depth=10))
LSFMod()
Crop(6,0,-14,-4).AddBorders(10,2,10,2)
10. Thank you for the script LMotlow it's kind of you. I'll look into it. I searched yesterday for a VCR that has a line tbc built-in, and it is just to expensive.. So I'll check if a could get/borrow and other vcr that does't sharpen as much. Meanwhile I checked into my boxes and found that I have a panasonic dvd recorder DMR-E100H, I'll see if I could use it as a pass-thru. If not I thought of trying to record directly with it, if I can found some kind of pass-thru between the vcr and the recorder that could bypass the copy right. But I don't know if the result would be be better. Otherwise I'll have to live with the poor result that I can get with my vcr...

Thank you very much, you help is very appreciate
11. That curving in the upper part of the video can be improved using V.C. Mohan's DeBarrel filter:

http://www.avisynth.nl/users/vcmohan/DeBarrel/DeBarrel.html

And perhaps by some other of the AviSynth skew filters:

http://avisynth.nl/index.php/External_filters#Rotation.2FShear.2FSkew.2FPerspective

But, as LMotlow mentioned, much better would be to get it right the first time.
12. The curving of the overall frame is only one problem that will be fixed by a line TBC. Another manifestation of poor horizontal time base is the way each scan line shifts left and right randomly from frame to frame. Vertical edges can be seen wiggling left and right rather than being straight and standing still. Here's short animation from the sample video, some vertical edges from one field, slowed to 2 fps and zoomed 4x for clarity:

Notice how the door frame isn't straight and wiggles from frame to frame. This cannot be fixed after capture. Not only does it look bad but it's also a killer of video compression.
13. Well it seems quite obvious that the main problem is the VCR, I will try with other vcrs but this VHS is not worth investing hundreds of dollars, to get a line tbc. Question is.. would I get as much problems if I would play directly to tv (VCR to tv) or is it the way I capture the video that cause most problems. Because like I said I could try to record/capture from the vcr to a dvd recorder which have a Hard disk drive. But if i get the same result or worst I will not bother to try, cause I'll have to pay a few bucks to get a macrovision killer or some kind of by-pass (if that really works!). Or if it is the capture method, would that be better to get somethig like a Diamond One-Touch Video Capture VC500 instead of my Hauppauge device (wintv7). Would it change anything considering that my vhs has not a line tbc, at least resolve some of the problem ?

If anybody as a opinion on this it would be helpful. (I am just trying to reduce harm with the material I have).

Thank you.
14. As fas the high-end tbc equipped super VCRs go, yes, they are often amazing performers. But you would still have the copy protection problem.

The pass-thru devices most often recommended and thoroughly tested are the Panasonic DMR-ES10 and DMR-ES15. Your H100 might work for pass-thru, but the question is one of correction power. You should give it a try as pass-thru, it might be just enough to fix the problem.

The VC500 is a very good capture device for use with Virtualdub or AmarecTV and has been tested here several times. It is far and above much better than the cheap copies that look like it but don't perform nearly as well.
15. An old Panasonic ES10 or ES15 DVD recorder will probably cost you about US\$100. If you're lucky you might find one with a defective DVD drive (it's not needed for passthrough) for much less.
16. Thanks guys. You do an amazing job here. I reconize the time it takes to answer us and give us those very relevant informations. It's very generous. I'll do some testing with the pass-thru, who knows I might get lucky with my DMR-E100H.
17. Originally Posted by Altruo
I might get lucky with my DMR-E100H.
Worth at try. If you can use s-video from the DVD recorder to your capture card, do so. That may get rid of the dot crawl artifacts. If not, this code will get eliminate most of it without damaging the rest of the picture too much.

Code:
function ABS_base(clip v, int base)
{
}

function ChromaEdges(clip v)
{
UtoY(v)
ConvertToRGB()
UEdges = GeneralConvolution(128, "
1  2  1
0  0  0
-1 -2 -1 ", 1).ConvertToYUY2().ABS_base(128)

VtoY(v)
ConvertToRGB()
VEdges = GeneralConvolution(128, "
1  2  1
0  0  0
-1 -2 -1 ", 1).ConvertToYUY2().ABS_base(128)

}

function RemoveDotCrawl(clip v)
{
AssumeTFF(v)
SeparateFields()
blurry = BilinearResize(width/2, height).Spline36Resize(width,height)
Weave()
}
Call RemoveDotCrawl() right after opening the source, while it's still YUY2.

Also, I went a little brighter and with more of a gamma stretch than you or LMotlow.

Code:
ColorYUV(gain_y=60, off_y=-32, gamma_y=60, cont_u=30, cont_v=30)
18. Good, very good ! I give it a try.

I will first try with the s-video since my capture card and the recorder have it. But just to make sure... the code goes to the avisynth script ? or as an .avsi into avisynth plugins file ?

So it would be:

The source
The code or RemoveDotCrawl()
TFM()
TDecimate()
and so on... ?

19. Importing an AVS script into your main script is the same as including the text of the imported script in your main script. Automatically importing an AVSI script is the same as importing an AVS script manually. Creating a function only makes that function available. You must still call it to apply it. The dot crawl functions were particular to this video so I would just include them in your main script.

Code:
function ABS_base(clip v, int base)
{
}

function ChromaEdges(clip v)
{
UtoY(v)
ConvertToRGB()
UEdges = GeneralConvolution(128, "
1  2  1
0  0  0
-1 -2 -1 ", 1).ConvertToYUY2().ABS_base(128)

VtoY(v)
ConvertToRGB()
VEdges = GeneralConvolution(128, "
1  2  1
0  0  0
-1 -2 -1 ", 1).ConvertToYUY2().ABS_base(128)

}

function RemoveDotCrawl(clip v)
{
AssumeTFF(v)
SeparateFields()
blurry = BilinearResize(width/2, height).Spline36Resize(width,height)
Weave()
}

AviSource(...)
RemoveDotCrawl()
TFM()
TDecimate()
Etc()
20. Super! thank you Jagabo

Statistics