![]() |
Success with Avisynth Median filter, it works wonders!
5 Attachment(s)
Just wanted to share how impressed I am with the median filter for Avisynth. So I though I'd give back to the community with a little write-up.
But first, an introduction. I'm capturing PAL VHS tapes. It's only recently that I started experiencing the joys (and pains) of Avisynth scripting. My capture workflow is as follows:
The video flowed as follows: NV-HS1000 (output toggled to S-Video) -> SCART CABLE -> DMR-ES15 -> S-Video cable -> VGB100 Captured in Virtualdub2 and encoded losslessly using the UTVideo 422 BT610 codec. I captured my VHS 3 times (the minimum needed to use the median filter). I loaded them up on Avisynth and I trimmed them at the start so that the first non-black frame was aligned. Code:
clip1= AVISource("D:\capture.ES15.take1.avi").trim(243,0)Code:
clip1f=clip1.crop(0,0,-360,0)Of course, sometimes it's hard to spot the exact moment when a frame is dropped in one of the 2 clips, especially if the frame is dropped in a low-motion sequence (I was literally giving myself headaches staring at single pixels). So the Subtract() function (which shows you just the difference between 2 clips) came in VERY useful: Code:
Subtract(clip1,clip2)Attachment 13319 However, when a frame is dropped from one of the two clips, the difference highlights the motion area very blatantly: Attachment 13320 Every time I found a frame that was missing from one of the 2 clips, I noted down the frame number and inserted it from the other clip using code like this: Code:
insertinto2_1 = clip1.trim(7880,7880) In total, I "patched" 22 frame drops across three 90-minute captures. Not bad, considering that without the ES15, I had hundreds of frame inserts over a single capture. I now had three clips perfectly aligned to the frame. LET'S MERGE THEM INTO A BETTER QUALITY VIDEO Here is a screenshot from one of the 3 captures: Attachment 13321 You can see the noise towards the top. this same frame was clean in the other 2 captures. so the median filter will know to discard the noisy pixels here. Here is the clip built by simply calling: Code:
median(clip1,clip2,clip3)Look at them side by side! It's incredible how much I could clean up the picture with a single filter. And the great thing is that I haven't introduced anything new into the picture, The filter hasn't degraded the video quality: in fact, it restored the video quality by extracting every last bit of detail from the VHS! I could, if I wanted, capture the same VHS another couple of times so I can median-filter 5 clips instead of 3. Not sure if the quality will improve a little bit more, or if I'll hit diminishing returns immediately. Might be worth a try. and finally, this is the median-filtered screenshot after going through QTGMC(Preset="faster",inputtype=1) Attachment 13323 Personally, I'm very happy with the results. I recommend this process to anyone who's trying to get the best possible quality out of their tapes. |
1 Attachment(s)
I tried the median of 3 captures (there is some saturation in the process, so 5 is not giving a significant difference). I noticed that the noise is somehow slightly reduced, so it was worth the effort, even if in your sample the problem on the top is more a defect than a noise problem.
However, using avisynth filters like TemporalDegrain or MCTemporalDenoise or SMDegrain or embedded QTGMC denoise on the single clip I obtain a better result. Concerning the pure noise, IMHO if you do not plan any avisynth restoration Median is good; if you plan avisynth denoise filtering is not necessary. But you can experiment yourself: apply TemporalDegrain with a soft setting on the first clip and compare. If you do, let us know the result! Concerning the defect on the top, Median did great, but you can also try some avisynth script for defect removal (decomet, destripe, much more complicated techniques, etc...), and again compare with Median. Jerry Calà :):):) -- merged -- This is an example of applying twice FixRipsp2 within a single clip on a defect similar to yours. In my case it is reduced but is not perfect. Maybe if you use it after Median() that already almost eliminated your problem, the final result will be perfect (or maybe worst) Attachment 13326 |
Quote:
First of all, the defect in the frame I showed is actually only happening in 1 capture out of the 3, so that's why median worked so well to remove it. There were other frames where I can see dropouts in all 3 captures, and median didn't do much. I think the only problem median can have is when a defect is present in the majority of the captures. In that case, median will pick the bad pixels and discard good detail that's got the misfortune to be in a minority of the captures. Still, I think Median is great for extracting the maximum quality from the tape. If the video in the tape is itself noisy, Median will retain the noise that's actually recorded in the tape, while removing the noise that was added during a each single playback and capture of the tape. I can still use any filter after Median to try and fix what Median couldn't. e.g. QTGMC after median is better than QTGMC by itself. |
Quote:
Code:
Median will retain the noise that's actually recorded in the tape,Try yourself applying, for example, TemporalDegrain on 1 clip and on the median of 3 clip. (I do not have anymore a comparison to post, sorry) If you do not plan denoising for whatever reason, Median is excellent to remove non repetitive noise or defect! |
2 Attachment(s)
Here's the comparison (done on a different frame):
TemporalDegrain2 on a single capture Attachment 13329 TemporalDegrain2 on a 3-capture median Attachment 13330 Seems to me that TD2 has created fewer artifacts on the median compared to the single capture. Personally, if I encode a capture to x264, I don't like to completely wipe out the noise. That would also wipe out the grain, and make the picture look washed out and waxy -- like a low quality, low bitrate video. So if I can get a more "accurate" noise, I'll take it :D |
4 Attachment(s)
Quote:
Attachment 13332 Attachment 13333 Let see what the metric says: Subtract and Compare Attachment 13334 SSIM analysis Attachment 13336 All this is based on the images, with colorspace conversion; if you wish to go deeper, better redo it with the video. Quote:
- washed out and waxy: after a denoising stage a sharpening is required, I generally use LSFmod. Try it and you'll see how the filtering improves! - I don't like to completely wipe out the noise: me neither, but the encoders do not like noise, and are less efficient in its presence. I am one of the few watching my captures in lossless format (I never encode except for youtube/facebook or forums) and I am not a x264 expert, but if you are going to encode noise could be a problem. - I agree that sometime a bit of noise is welcome to make the digital videos less "digital", but noise and grain are not exactly the same: I think is better to reinject some of the "noise" with AddGrain or similar or some parameters available for the denoisers, because they knew what they did. An example here https://forum.doom9.org/showthread.php?t=147796 Thanks for the enjoyable discussion! |
2 Attachment(s)
Hey, thank you for engaging! :)
Let me just first point out what the 3-capture median workflow allowed me to achieve with this clip:
Quote:
I see you posted shrunk down JPEGs. I can only see JPEG artifacts there, plus the screenshots are tiny and we lost all detail :D Let's compare the screenshots again, zoomed in and saved as PNG this time: Attachment 13340 Attachment 13341 Notice the jagged, fuzzy edges, and the overall noise in the single capture compared to the median. Sure, more filters could further improve the single capture, but the same filter will certainly give a better result on the median-filtered clip. Quote:
|
Fisrt of all let me clarify that I love multiple captures technique as you do, but I think that in the case I explained (clean capture, further restoration) is not really necessary because it requires a lot of effort.
To remove occasional defects or defect showing themself in a differente way across the capture is excellent , but in general needs to be followed by a restoration anyhow (I experimented that a "trace" of my defects will stay in all captures in most of the case, YMMV). Quote:
Quote:
There is indeed some small difference (for sure Compare does not say 100dB overall), but very very marginal and it will not be seen in a standard play. All this is based on the images you posted, surely not a "orthodox" method. Quote:
Quote:
Quote:
Quote:
Quote:
|
1 Attachment(s)
A probable reason for the noise band in the upper part of the first still is a piece of dirt on the tape. The effect is way beyond the capabilities of the DOC to mask it. But the problem with multiple captures is there's no guarantee that on subsequent passes the piece of dirt will obediently remove itself. Playing the tape two or more times seems a lot of time and effort hoping that luck will favour us. It seems kind of hit or miss.
Here's a link to a Specs Bros White Paper on the benefits of tape cleaning. http://www.specsbros.com/white-paper-the-benefits-of-tape-cleaning.html The great thing about tape cleaning is that it cleans off dirt and other contaminants regardless of whether we've seen or heard its effects on picture and sound, and in a tape which might run to hours. There's less need to monitor the entire program second by second looking for possible faults due to a dirty tape. The artifacts - and there could be many of them in many frames - could have been avoided in the first place, before capture, by proper tape cleaning. As the paper says, the cleaning applies just as much to the player deck as to the tape. |
Quote:
Sure there's also noise that happens in the majority of captures, and they will defeat median filtering. But they're fewer and easy to address later, if needed, once you've done multiple captures. Tape cleaning... that looks hardcore. There's always something extra we can do to squeeze a little bit of extra clarity or less noise from a tape ;) |
Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.