View Full Version : How to clean-up those blocky flv videos
dexy
26th February 2007, 16:13
Hi guys, you have, probably, downloaded many videos from YouTube etc. Video quality is really poor, so it needs to be deblocked and derringed. For deblocking I am using mpeg2dec deblock filter, and it does the job on static scenes, but on fades blocks are still there. For derringing, btw, I have no idea which filter to use. I wanna know which filters do you prefer for those kinds of video, and which settings can do the job great.
:thanks:
foxyshadis
27th February 2007, 00:53
How much time are you willing to put into it? You can use DegrainMedian, MipSmooth, TTempSmooth, FFT3DFilter, all the way up to MVDegrain, in a rough order of speed and quality. However, in such badly damaged video there usually isn't a lot of real detail left hidden under all the noise, so you're going to have to accept some amount if you don't want it to look cartoony.
When I'm home I can post one of the scripts I use for recovering youtube video, if you like.
Terranigma
27th February 2007, 00:58
When I'm home I can post one of the scripts I use for recovering youtube video, if you like.
I'd like to see the script. I'm thinking it's a script using mvdegrain :)
Chainmax
27th February 2007, 03:40
I normally use something based on a recommendation Didée gave me a long time ago for some insanely crappy 160x120 digicam videos:
- deblock_QED (remove blocking, but keep detail) (-> it's on kassandro's forum, search)
- soft upsampling (perhaps gaussian) to ~150%
- extreme LimitedSharpen (updated version), with Smode=3, strength=1000, wide=true, soft=75~100
- 2x Upsampling by EEDI2, or custom script with good old SangNom
- lanczos to final destination size
- temporal filtering somewhere inbetween, perhaps MC'ed
- eventually use SeeSaw instead of LimitedSharpen, or even both
The most extreme variation that I had to use was with the two anime versions of the 1992 X-Men series's intro, the script for both was this one:
DirectShowSource("C:\X-Men Anime Intro Nº1.flv",fps=25,convertfps=true,audio=false)
ConvertToYV12()
FixChromaBleeding()
FFT3DFilter(sigma=6,plane=3,bw=32,bh=32,bt=3,ow=16,oh=16)
Tweak(sat=1.4)
DeHalo_Alpha()
DeGrainMedian()
Deblock(quant=35)
Crop(2,2,318,236,align=true)
GaussResize(448,336)
EEDI2().TurnRight().EEDI2().TurnLeft()
Spline36Resize(656,448)
aWarpSharp(depth=16,cm=1)
LimitedSharpenFaster(Strength=200)
vmToon(strength=150,thinning=0)
gradfun2db()
AddGrain(5,0,0)
AddBorders(24,16,24,16)
Levels(0,1,255,16,235)
(I changed the location of the gradfun2db line in order to reflect further advice I've gotten about this filter)
Here's a before/after comparison with the latter script:
http://img144.imageshack.us/img144/3234/wolverineox9.png (http://imageshack.us)
Yeah, the source was resized with PointResize to emphasize the difference, but I doubt using better resizers for the source picture would have changed the purpose of the comparison too much.
I figured the framerate thanks to tritical and foxyshadis's advice: using FLV Extractor to extract the timecodes, then the AVI_TC package to convert the timecodes to v1 and see what was the most common fps in the v1 list and/or if all framerates were close to being all submultiples of a single greater one.
dexy
27th February 2007, 23:25
@foxyshadis
Time is not metter, the only important thing to me is quality. I am planning to filter some videos which are actually clean off noise, the only thing I have to do is deblock/derring. But, maybe I will met some noisy video some time, so every suggestion about cleaning the noise is welcome too. I will agree with Terranigma, post your script when you have time to do that. Thanks...
@chainmax
Thanks... Hm, as I can see there are some artifacts still present on places where the color has been destroyed, but in comparasion with source, video looks really great. Which script do you most frequently use?
Chainmax
28th February 2007, 00:01
The script I most commonly use would be something along the lines of:
DirectShowSource("X:\wherever\myvideo.flv",fps=X,convertfps=true,audio=false)
ConvertToYV12()
Deblock_QED()
Crop(whatever,align=true)
GaussResize(cropped_width*sqrt[1,5],cropped height*sqrt[1.5])
dull=last
sharp=dull.LimitedSharpenFaster(SMode=4,Strength=1000,wide=true,soft=75)
Soothe(sharp,dull,25)
EEDI2().TurnRight().EEDI2().TurnLeft()
FFT3DFilter(sigma=1,bw=32,bh=32,bt=3,ow=16,oh=16,sharpen=0.7)
Spline36Resize(final_width,final_heigth)
Tweak(sat=1.2)
gradfun2db()
AddGrain(5,0,0)
Levels(0,1,255,16,235)
If more deblocking is needed, I raise DeBlock_QED's quant1 and quant2 parameters, readjusting aOff1 and aOff2 accordignly so that quant1+aOff1 = quant2+aOff2 = 51. If that's not enough, I add DeGrainMedian() right after DeBlock_QED. If that's still not enough, I use the original script but replace DeBlock_QED() by DeBlock(). Is most cases, the video will have some rainbowing, so I use FFT3DFilter on the chroma planes (plane=3) with a sigma of 3 right after the ConvertToYV12() line. If halo removal is needed, I use DeHalo_Alpha() somewhere in the script.
Terranigma
28th February 2007, 17:52
Pardon my ignorance, but what benefit is there to using this line
EEDI2().TurnRight().EEDI2().TurnLeft()
? for extra deblocking, smoothing, something else?
Chainmax
28th February 2007, 19:11
In addition to doubling the resolution (which is always preferable to the graphics card's bilinear stretch IMO) and some very slight extra smoothing, its main use was pointed out by foxyshadis some time ago, and it consists of reconstructing outlines and borders that were destroyed by the blocking.
foxyshadis
2nd March 2007, 09:19
Sorry, I lost my cool script somewhere and haven't had time to put it back together. I could have thrown together something based on random scharfi, Didée, Mug Funky, and Chainmax scripts scattered around, but I think you want something that'll finish this month. :p
Pookie
2nd March 2007, 12:20
Perhaps the EEDI2().TurnRight().EEDI2().TurnLeft() line would be more useful if it was earlier in the script. Once you've hit the video with your multitude of filters, resize back down to the original dimensions. It'll hide the filtering artifacts (pretty much).
*.mp4 guy
2nd March 2007, 13:29
This is a pretty good all purpose script for tough sources, Its supposed to preserve whatever detail is in the source, though, so it won't be as artefact free as some of the more aggressive scripts.
source = last
w = source.width
h = source.height
backward_vec2 = source.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
backward_vec1 = source.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec1 = source.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec2 = source.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
maskp1 = mvmask(kind=1, vectors=forward_vec1, ysc=255).UtoY()
maskp2 = mvmask(kind=1, vectors=forward_vec2).UtoY()
maskp3 = mvmask(kind=1, vectors=backward_vec1, ysc=255).UtoY()
maskp4 = mvmask(kind=1, vectors=backward_vec2).UtoY()
maskf = average(maskp1, 0.25, maskp2, 0.25, maskp3, 0.25, maskp4, 0.25).spline36resize(w, h)
smooth = source.degrainmedian(mode=3, limity=16, limituv=8).fft3dgpu(bw=16, bh=16, bt=3, sigma=4, plane=0)
source2 = maskedmerge(source, smooth, maskf)
source3 = source2.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)
source3
For stronger processing use higher values of thSAD and Sigma
dexy
2nd March 2007, 17:26
This gonna be a long day. To load those scripts I need a fully reorganization of plugins.:rolleyes: Sorry for offtopic, but I need to get a quick answer:) ; As I understood, I need to split old and new plugins, new I should put into the autoload directory, and for those old I must create function which will autoload them via loadpluginex. Am I right?
*.mp4 guy
2nd March 2007, 19:38
Yes. <- This is apparently too short of a message, the message is now longer. Isn't that great.
dexy
2nd March 2007, 20:00
Isn't that great
Yes, yes it is. ;-) Thanks...
DSP8000
3rd March 2007, 06:48
maskf = average(maskp1, 0.25, maskp2, 0.25, maskp3, 0.25, maskp4, 0.25).spline36resize(w, h)
I'm getting script error "there is no script function "average"
Am I missing something? Probably Yes :D
Any hints?
:thanks:
foxyshadis
3rd March 2007, 07:15
http://forum.doom9.org/showthread.php?t=100626
DSP8000
3rd March 2007, 09:02
Tnx. foxyshadis.
The script provided by .mp4guy didn't do it for me at all.
This is what I'm using for the "blocky FLV videos", borowed goods from Chainmax with modification:
DirectShowSource("D:\YOU_TUBE_VIDEO.flv")
ConvertToYV12()
LanczosResize(352,288)
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\fft3dfilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\deblock.dll")
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpenFaster.avsi")
FFT3DFilter(sigma=3,plane=4)
DeGrainMedian(mode=3)
Deblock(quant=30)
LimitedSharpenFaster(Strength=160)
Levels(0,1,255,16,235)
Faster & better results.
Adjust strenght of deblocking/denoising accordingly
*.mp4 guy
3rd March 2007, 10:21
I didn't realise they were that bad, fft3d with sigma4 and deblock with quant 35, your videos must have been really mangled. Some youtube stuff is reasonably good, was your source very high motion?
DSP8000
3rd March 2007, 10:46
Yeah, they we're that bad, considering that these videos that I have are low quality+recompression from YouTube=strong deblocking,denoising...
But, then again, every script has to be adjusted accordingly to the current video source, coz, one size does not fit all.
I'm making a DVD for a friend of mine(he's into gypsy music) so we'll see how all comes out.
Thanks for sharing your script with us :)
Pookie
3rd March 2007, 13:09
*.mp4 guy -
source2.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=2)
(I'm surprised Didee hasn't pointed that one out yet :D )
There is no idx 2 (but I did play around with that script and you're right - it is pretty good with higher noise sources)
Chainmax - Fine job on the deblocking!
I'm wondering if that new Threshold script by mf might be useful in situations where blocking occurs in moving scenes - as in every flv file on gootube...
*.mp4 guy
3rd March 2007, 13:16
Idx 2 is correct, using idx 1 would mitigate most of the smoothing done on high motion scenes by reusing the interpolation data from the non smoothed source.
Pookie
3rd March 2007, 13:18
Then I stand corrected.;)
plonk420
27th October 2014, 06:39
The script I most commonly use would be something along the lines of:
DirectShowSource("X:\wherever\myvideo.flv",fps=X,convertfps=true,audio=false)
ConvertToYV12()
Deblock_QED()
Crop(whatever,align=true)
GaussResize(cropped_width*sqrt[1,5],cropped height*sqrt[1.5])
dull=last
sharp=dull.LimitedSharpenFaster(SMode=4,Strength=1000,wide=true,soft=75)
Soothe(sharp,dull,25)
EEDI2().TurnRight().EEDI2().TurnLeft()
FFT3DFilter(sigma=1,bw=32,bh=32,bt=3,ow=16,oh=16,sharpen=0.7)
Spline36Resize(final_width,final_heigth)
Tweak(sat=1.2)
gradfun2db()
AddGrain(5,0,0)
Levels(0,1,255,16,235)
If more deblocking is needed, I raise DeBlock_QED's quant1 and quant2 parameters, readjusting aOff1 and aOff2 accordignly so that quant1+aOff1 = quant2+aOff2 = 51. If that's not enough, I add DeGrainMedian() right after DeBlock_QED. If that's still not enough, I use the original script but replace DeBlock_QED() by DeBlock(). Is most cases, the video will have some rainbowing, so I use FFT3DFilter on the chroma planes (plane=3) with a sigma of 3 right after the ConvertToYV12() line. If halo removal is needed, I use DeHalo_Alpha() somewhere in the script.
any suggestion for 1080p mpeg4 tech videos? well, i guess WMV. this script blew up VirtualDub which i use to visually check filter results. i'm assuming you end up with a 7680x4320 video at one point (or something with a similar number of pixels).
.mp4 guy's blew away the most detail, but also removed the annoying way blocks kinda flicker or swim around edges of objects.
and the DSP8000 was still pretty blocky...
foxyshadis
28th October 2014, 00:16
It shouldn't be that bad. The Resize line should be GaussResize(m4(width*1.2),m4(height*1.2)) where m4 is function m4(float i) { return int(i/4.0)*4 } (This is sometimes present in an avsi script already.) It'll never go above 4608x2592, which shouldn't be too hard to process, it works OK for me. Doubled up like that, FFT3DFilter is probably hardly going to do much, though.
plonk420
28th October 2014, 07:11
ah, it seems it doesn't like
FFT3DFilter(sigma=1,bw=32,bh=32,bt=3,ow=16,oh=16,sharpen=0.7)
i uncommented lines. until i did
EEDI2().TurnRight().EEDI2().TurnLeft()
it was under 100MB. once i did that, it hit ~380MB RAM. and then when i threw in FFT3DFilter, it took a dump :S "Error reading source frame 0: Avisynth read error: CAVIStreamSynth: System exception - Access Violation at 0x67886b09, writing"
edit: was able to throw everything else back into the script sans fft3dfilter. it doesn't look TOO bad at the SD resolution i was shooting for, but i wish i knew more to find a way to lessen the blocking...
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.