Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
19th March 2015, 00:25 | #21 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Code:
Import("D:\avs\Bank\MCDegrain.avs") # Import is exactly the same as Pasting the script function HERE. Avisource("D:\avs\test.avi") # Clip in special Last variable as not assigned to anything MCDegrain(3) # Calls MCDegrain using implicit Last clip variable, as not explicitly supplied. Return Last Code:
Avisource("D:\avs\test.avi") # Clip in special Last variable as not assigned to anything MCDegrain(3) # Calls MCDegrain using implicit Last clip variable, as not explicitly supplied. Return Last Function MCDegrain(clip c, int "frames") { # By Didee, http://forum.doom9.org/showthread.php?p=1508289#post1508289 frames = default(frames, 2) bs = (c.width>960) ? 16 : 8 super = c.MSuper(pel=2, sharp=1) backward_vec3 = MAnalyse(super, isb = true, delta = 3, blksize=bs, overlap=bs/2) backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=bs, overlap=bs/2) backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=bs, overlap=bs/2) forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=bs, overlap=bs/2) forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=bs, overlap=bs/2) forward_vec3 = MAnalyse(super, isb = false, delta = 3, blksize=bs, overlap=bs/2) (frames<=0) ? c :\ (frames==1) ? c.MDegrain1(super, backward_vec1,forward_vec1,thSAD=400) :\ (frames==2) ? c.MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) :\ c.MDegrain3(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=400) return(last) } Code:
Function MCDegrain(clip c, int "frames") { # By Didee, http://forum.doom9.org/showthread.php?p=1508289#post1508289 frames = default(frames, 2) bs = (c.width>960) ? 16 : 8 super = c.MSuper(pel=2, sharp=1) backward_vec3 = MAnalyse(super, isb = true, delta = 3, blksize=bs, overlap=bs/2) backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=bs, overlap=bs/2) backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=bs, overlap=bs/2) forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=bs, overlap=bs/2) forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=bs, overlap=bs/2) forward_vec3 = MAnalyse(super, isb = false, delta = 3, blksize=bs, overlap=bs/2) (frames<=0) ? c :\ (frames==1) ? c.MDegrain1(super, backward_vec1,forward_vec1,thSAD=400) :\ (frames==2) ? c.MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) :\ c.MDegrain3(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=400) return(last) } Video = Avisource("D:\avs\test.avi") # assigned to Video Video2 = MCDegrain(Video,3) # Calls MCDegrain using Video clip variable Return Video2
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
19th March 2015, 15:06 | #23 | Link |
Registered User
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
|
@stainlesss - principally I was successful with Your scriptsamples. The result is good and improves my noisy Hi8 sources nicely.
I am mostly working with 720x576i ProRes files. I think therefore I have some fields issues with the interlaced material. My actual Adaptation of Your script Looks like this: Code:
SetMemoryMax(1024) SetMTMode(5,6) #~ AVISource("c:\videodaten\intensitytest8mm.avi").ConvertToYV12.AssumeTFF().waveform().SeparateFields() # Clip in special Last variable as not assigned to anything qtinput("C:\myvideo.mov", color=2, audio=1).ConvertToYV12.AssumeTFF() SetMTMode(2) MCDegrain(3) # Calls MCDegrain using implicit Last clip variable, as not explicitly supplied. (1=light/3=full) return last Function MCDegrain(clip c, int "frames") { # By Didee, http://forum.doom9.org/showthread.php?p=1508289#post1508289 frames = default(frames, 2) bs = (c.width>960) ? 16 : 8 super = c.MSuper(pel=2, sharp=1) backward_vec3 = MAnalyse(super, isb = true, delta = 3, blksize=bs, overlap=bs/2) backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=bs, overlap=bs/2) backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=bs, overlap=bs/2) forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=bs, overlap=bs/2) forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=bs, overlap=bs/2) forward_vec3 = MAnalyse(super, isb = false, delta = 3, blksize=bs, overlap=bs/2) (frames<=0) ? c :\ (frames==1) ? c.MDegrain1(super, backward_vec1,forward_vec1,thSAD=400) :\ (frames==2) ? c.MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) :\ c.MDegrain3(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=400) # Crops xx pixels L,T,R,B and resizes to 720x576: Crop(10, 4, -14, -10).LanczosResize(720, 288) Weave() return(last) } Where do I insert the crop and resize arguments?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore Last edited by papcom; 19th March 2015 at 15:15. |
19th March 2015, 18:31 | #24 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
I think there is a script function called McDegrain2i2() (or something like that), I rarely keep interlacing, dont like it and pretty much always get rid for either computer or hand held display. I see JohnMeyer on-line, perhaps he can advise on the interlaced version of MCDegrain (I looked at wiki and did not spot it). EDIT: And you cannot just resize interlaced material, that would screw it up (others would be better placed than I to advise on that).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 19th March 2015 at 18:46. |
|
19th March 2015, 18:57 | #25 | Link | |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,691
|
Quote:
I seldom use the re-size function. It was created by someone in these forums, and seemed to work pretty well, but I make no claims beyond that. Block size of 8 is usually good for VHS. You get better quality in the shadows and in flat areas if you use an overlap of 2 or 4 (overlap must be mod2, I think). However, using larger overlap values will slow down the script. Use the commented out stackhorizontal line to view the before/after side-by-side to see if you get better results with different overlaps. You can also experiment with block sizes of 4 (slower) or 16 (faster) to see if the quality is better or worse. Smaller block sizes do not always result in better quality and are therefore not worth the considerable performance penalty. Most important, play around with the strength parameter. This may have to be adjusted when you change block size. I also have another version that uses MRecalculate in the motion estimation which sometimes (although not always) produces better results, in less time. As always, even if you don't change the script, you will need to tune the block size, overlap and strength to fit your particular needs. There is no "one size fits all" approach. Code:
SetMemoryMax(768) Loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll") SetMTMode(5,6) source=AVISource("E:\fs.avi").killaudio().AssumeBFF() SetMTMode(2) output=MDegrain2i2(source,8,2,400,0) #output=IResize(output,720,480) #stackhorizontal(source,output) return output #------------------------------- function MDegrain2i2(clip source, int "blksize", int "overlap", int "strength", int "dct") { fields=source.SeparateFields() # separate by fields super = fields.MSuper(pel=2, sharp=1) backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct) forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct) backward_vec4 = super.MAnalyse(isb = true, delta = 4, blksize=blksize, overlap=overlap, dct=dct) forward_vec4 = super.MAnalyse(isb = false, delta = 4, blksize=blksize, overlap=overlap, dct=dct) MDegrain2(fields,super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=strength) Weave() } function IResize(clip Clip, int NewWidth, int NewHeight) { Clip SeparateFields() Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0) E = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0, Shift) O = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -Shift) Ec = SelectEven().Spline36Resize(NewWidth, NewHeight/2, 0, 2*Shift) Oc = SelectOdd( ).Spline36Resize(NewWidth, NewHeight/2, 0, -2*shift) Interleave(E, O) IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last Weave() } |
|
19th March 2015, 18:59 | #26 | Link |
Registered User
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
|
thanks @stainlesss for your hints.
Yes there is MDegrain2i2 . I used it already in a script-sample of Johnmeyer, which gives also a good result. I just wanted to try Your (or Didee's) script, but I wasn't aware that interlacing and crop/resize could make difficulties. EDIT: @johnmeyer, thank you - I just tried Your above script Proposition. It's fast and neat. I would Need resize because I am always cropping on the sides, as well as top and bottom. Where in Your script would You suggest to insert the cropping?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore Last edited by papcom; 19th March 2015 at 19:12. Reason: Just saw the positing of Johnmeyer |
19th March 2015, 19:08 | #27 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Thanks for posting the functions John, I've snatched a copy of both.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
19th March 2015, 19:17 | #28 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Make sure top and bottom crop by multiple of 4 (else damage interlacing).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
19th March 2015, 19:20 | #29 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
That Iresize ain't no nice solution somehow
U need to resize the interlaced crap progressively where there ain't no motion And do what "iresize" does where there're moving objects Then merge'em with a motion mask |
19th March 2015, 19:22 | #30 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
And do you have a spoon fed recipe for such ?
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
19th March 2015, 19:28 | #32 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Is that a 'no' then ?
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
19th March 2015, 19:42 | #34 | Link | |
Registered User
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
|
Quote:
Code:
function IResize(clip Clip, int NewWidth, int NewHeight) Code:
output=IResize(output,720,576) I put the crop into the function MDegrain2i2, just before Weave() ...this crops the Video, but I am unsure. Where is the correct place for the "crop" of interlaced video
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore Last edited by papcom; 19th March 2015 at 19:57. |
|
19th March 2015, 19:50 | #35 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,691
|
I direct all those critical of the IResize function to read the long thread where it was developed:
Deinterlace should preserve original pixels? Much of the discussion was between Gavino and IanB. This particular post, within the thread, provides the first step towards code I used: IResize The actual IResize function appears a few posts after this one. I think the argument being made here is that one should use a smart bobber instead of separatefields. However, the point of all the extra code in the IResize function is to provide the re-alignment of a bobber, but with extra adjustments to provide correct shifting for the chroma. As I said in my original post above, I don't use this function much, and I made no claim about the quality of its results. However, when I did use it, I noticed no problems, and the people who developed it have shown, over the years, that they know what they are doing. Perhaps someone should try it, and post the results? |
19th March 2015, 20:04 | #36 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
@johnmeyer
You could try to iresize any progressive clip and the artifacts should pop out any moment I know it's wrong to iresize progressive clips for sure, but there's no 100% interlaced clip, if the interlaced clip contains any still motionless scene, it would suffer the same |
19th March 2015, 20:05 | #37 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,691
|
Taking my own advice, I just resized some 1440x1080 HDV interlaced ballet footage. I looked at fast moving sections where the dancers were leaping and saw absolutely no "ugliness." In fact, I would be hard-pressed to spot any artifacts. I'd post the results, but it would be a case of "nothing to see here, keep on moving ..."
I think I understand the concept of using motion estimation in order to be able to temporarily align each frame's two fields in time so that the resolution (spatial data) from the odd field can be used when resizing the even field (and vice versa). However, since motion estimation also introduces errors, using it may or may not produce a better result. This technique has at least one advantage in that its results are consistent from frame to frame. By at least doing a separatefields (or a bob), you avoid the huge problem of resizing both fields of interlaced footage at once, i.e., resizing at a frame rather than a field level. That produces completely unusable footage. You must resize at a field level when dealing with interlaced footage. Last edited by johnmeyer; 19th March 2015 at 20:21. |
19th March 2015, 20:13 | #38 | Link | |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,691
|
Quote:
However, I just went back to my ballet footage, which I took on a tripod. There are sections where the camera is not panning, and the background is absolutely still. I see absolutely nothing "bad" going on. This is true whether I look at the result field-by-field, or frame-by-frame. Here is the result of resizing to 720x480 from 1440x1080: Re-sized Test Clip [edit]Here's the HDV source for that "re-sized test clip": Source Clip Last edited by johnmeyer; 19th March 2015 at 20:20. Reason: Added source clip |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|