Log in

View Full Version : Degraining script assist?


Pages : [1] 2

Bruce/Fl
3rd September 2015, 07:49
Hello all,

I am an extreme avisynth noob, and hoping that I can get an assist here. Here is my situation.

I am in the process of having some old family 8mm films transferred. I am having it done by cinepost, so the results should be very good, although pricey. And they are very good, especially when I compare them to an earlier VHS transfer from about 25 years ago. In fact they are so good that I find myself actually wishing I could smooth out a bit of the now very easy to see and inherent grain from the source. I saw an example of Freds work online, and was really impressed. Since then I saw some of John Meyers work as well and was really impressed once again. That is what led me here.

As far as video editing programs go, I have been using Vegas 13 Pro. I use it to edit my present day Canon Vixia HD tape files. (ripped with HDVSplit)

I have gone to avisynth.org, and went through some of their tutorials, and so far so good. I am sloooowly learning to write code. (I am not always understanding exactly why I am writing what I write, but it is working). I have messaged John Meyer some and he sent me just the degraining segment of his code, but all of the other peripheral code that is needed to get it to run, well, at this stage of my learning I have no idea how to put it all together.

Additionally, I am working with .mov files, so I believe this is what I need to use, per John Meyer.

LoadVFAPIPlugin("C:\Program Files\AviSynth 2.5\plugins\QTReader.vfp", "QTReader")
QTReader("C:\xxxxxxxx\xxxxxx\xxxxx.mov")

As I mentioned, I have had no luck getting a degraining script to run. Anything beyond the very basic avisynth commands has foiled me. I *was* able to run Freds complete script, by downloading it and all of it's peripherals. It ran for me, and I got the split screen results. It looked horrible, because it was much more tweaking than I needed, but hey, it works. I *can* do this, if I have a complete script.

Anyways, as I was saying, I am getting many rolls of film transferred. Cinepost did the first 100' off of one of my 7" reels as a test run to give me a sample, to see if I wanted to go forward. As I mentioned, it'll be pricey, but I want to do it. I'm hoping to tweak the results some with a degraining script to make them even more impressive, and then hopefully my sister will see the value in it and I'll get some help from her on paying for it, (we'll split the cost). It will be over $1K initially, and then I'll have a few more reels on top of that, a little later. I'm having Cinepost hold my first 7" reel, and they are waiting for my go ahead to finish it off. Then, after being able to show the results to my sister and knowing she's financially in with me on this project, I'll send the rest of the first batch of reels.

All of which is the reason for my post. Could anyone here show me a complete script that will do some degraining for me? Something that all I will need to do is insert the path to my original file to and then run? I have avisynth downloaded, virtualdub, and a few other assorted programs and some dll's. I have a frame server loaded into vegas and have seen it work as advertised. Let me know what I'll need if I don't have it already and I'll get it and install it.

I hope to eventually get familiar with this script writing to be able to understand this better, but if I waited until I could do this all without a helping hand it would take forever. I'm hoping to be able to, once I tweak my sample file and impress my sister, give the go ahead to proceed in the very near future. I hope to make it so stunning of a difference it is a no brainer for her.

All that said, the look of the film after reducing the graininess some may not end up being what I am hoping for, and in that case, I'll just leave it as is. But having seen what is possible with avisynth, I am very hopeful that it will look even better.

Can anyone assist with a complete script? Ideally something that allows me to experiment with the amount of degraining being done, by changing a number here and there in the script.

Thank you

videoFred
3rd September 2015, 08:13
Hi Bruce,



Can anyone assist with a complete script? Ideally something that allows me to experiment with the amount of degraining being done, by changing a number here and there in the script.

Thank you

This is what my script and John's script already does ;)

But I assume you want something more simple, to start with Avisynth and to learn everything. Is it possible to upload an example clip? Then we can see what you need.

Fred.

Bruce/Fl
3rd September 2015, 08:34
hi Fred,

PM sent, inquiring about exactly what you'd like.

Reel.Deel
3rd September 2015, 14:48
@Bruce/Fl

Post a sample for everyone.


Additionally, I am working with .mov files, so I believe this is what I need to use, per John Meyer.

LoadVFAPIPlugin("C:\Program Files\AviSynth 2.5\plugins\QTReader.vfp", "QTReader")
QTReader("C:\xxxxxxxx\xxxxxx\xxxxx.mov")


QTReader is really old, I would recommend LSMASHSource (http://avisynth.nl/index.php/LSMASHSource).

LSMASHVideoSource("xxxxx.mov")

johnmeyer
3rd September 2015, 15:38
I received six separate PMs from the OP over at Videohelp.com, where he is also pursuing this same topic. I responded, at great length, to each PM. Eventually I realized that he is having problems with the basics, like how to read an MOV file into AVISynth. I eventually had to give up because I wasn't able to help him. Before I gave up, I did send him the basic degraining code that is in my version of Fred's script, and which is taken, more or less intact, from the MVTools2 documentation.

Here's what I sent:

prefiltered = RemoveGrain(stabcrop,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super= MSuper(stabcrop, hpad=32, vpad=32,pel=2)

halfblksize= (block_size>4) ? block_size/2 : 4
halfoverlap= (block_over>2) ? block_over/2 : 2

bvec1 = MAnalyse(superfilt, isb = true, delta = 1, blksize=block_size, overlap=block_over,dct=0)
bvec1 = MRecalculate(super, bvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec1 = MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over,dct=0)
fvec1 = MRecalculate(super, fvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

bvec2 = MAnalyse(super, isb = true, delta = 2, blksize=block_size, overlap=block_over,dct=0)
bvec2 = MRecalculate(super, bvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec2 = MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over,dct=0)
fvec2 = MRecalculate(super, fvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

denoised=stabcrop.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)

However, since this used variables from earlier in the script, he didn't know how to change the variables. If someone wants to help this person, you need to give him a script, absolutely complete, that will read an MOV file, and which will degrain film grain. That was more than I was able or willing to do, but that is what is needed.

Perhaps I should have simply copy/pasted that MVTools2 sample code. Heck, here it is:

AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
super = MSuper(pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)

There, that will degrain "test.avi". All you have to do is replace that first line with one that will read your MOV file, and you should get some degraining results. Increase or decrease the thSAD number (currently 400) to change the amount of degraining.

feisty2
3rd September 2015, 17:15
thSAD=denoising_strength
thSAD ain't no "denoising_strength"... like, really not, way not
I know cuz I just read the code of mvtools and wrote my own ultra high precision (32bits float) branch
thSAD is like, more of the tolerance of imperfect motion estimation, larger thSAD = messed up motion vectors with lots of errors would still be, like, okay, acceptable and join the process
the real strength of MDegrain is "tr", larger tr = higher strength

Bruce/Fl
3rd September 2015, 17:43
I received six separate PMs from the OP over at Videohelp.com, where he is also pursuing this same topic. I responded, at great length, to each PM. Eventually I realized that he is having problems with the basics, like how to read an MOV file into AVISynth. I eventually had to give up because I wasn't able to help him. Before I gave up, I did send him the basic degraining code that is in my version of Fred's script, and which is taken, more or less intact, from the MVTools2 documentation.

Here's what I sent:

prefiltered = RemoveGrain(stabcrop,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super= MSuper(stabcrop, hpad=32, vpad=32,pel=2)

halfblksize= (block_size>4) ? block_size/2 : 4
halfoverlap= (block_over>2) ? block_over/2 : 2

bvec1 = MAnalyse(superfilt, isb = true, delta = 1, blksize=block_size, overlap=block_over,dct=0)
bvec1 = MRecalculate(super, bvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec1 = MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over,dct=0)
fvec1 = MRecalculate(super, fvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

bvec2 = MAnalyse(super, isb = true, delta = 2, blksize=block_size, overlap=block_over,dct=0)
bvec2 = MRecalculate(super, bvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec2 = MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over,dct=0)
fvec2 = MRecalculate(super, fvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

denoised=stabcrop.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)

However, since this used variables from earlier in the script, he didn't know how to change the variables. If someone wants to help this person, you need to give him a script, absolutely complete, that will read an MOV file, and which will degrain film grain. That was more than I was able or willing to do, but that is what is needed.

Perhaps I should have simply copy/pasted that MVTools2 sample code. Heck, here it is:

AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
super = MSuper(pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)

There, that will degrain "test.avi". All you have to do is replace that first line with one that will read your MOV file, and you should get some degraining results. Increase or decrease the thSAD number (currently 400) to change the amount of degraining.

Hello John, Everyone,

A little background. just so everyone knows the story.

The night I initially contacted you, after first seeing Freds and then your work, I checked out various online resources looking for more info on this wonderful avisynth scripting. I was sent to doom9 first, where I started my researching. But I was not a member here yet, so I looked other places as well. I am a member over at Videohelp, and when I popped in there I saw your name over there as well, and that is why I reached out to you there. It wasn't that I was "pursuing this same topic" over there on their boards, but rather my recognizing your name over there, so I PM'd you using that forum. I don't want it to appear that I was over there sucking them dry of knowledge, and when done tossing them aside and coming here, in fact I never brought up the subject over there at all, I simply PM'd you using their messaging.

And your responses to my questions were very detailed, and I will once again thank you for the time and effort you put into trying to educate me. I am trying to learn about this scripting, but it is totally foreign to me, which you saw from my questions I am sure. I am still going through tutorials and working with more complicated scripting, but it is a very slow process. But regardless, after a few back and forth messages I gathered a sense that what I was trying to accomplish in contacting you, was most likely irritating you to some degree, so I stopped, and it looks like my instincts were correct, as you said above, what I was hoping for "... was more than I was able or willing to do". But once again, thank you very much for your efforts, and maybe someday soon I will be able to "talk shop" with you and others here when I actually have more of a clue as to what I am talking about. Because in my messages with you, and also here on my initial post, I tried to be very clear that I am very, very new to this and my knowledge is very, very limited in this area. I'm hoping I was clear on that as well here, I'm not trying to anything sneaky, I just need help.

But at the forefront of all of this is that I am hoping someone will help me jump ahead quickly in this scripting, on solely the degraining aspect, for the purpose of hopefully improving what Cinepost sent me so I can show my Sister what is possible, and that she will feel better about making a monetary contribution. All of the rest of the capabilites avisynth gives you, stabilization, adjusting levels, sharpening, etc., I am fine with learning as I go. It is only the degraining aspect of it that has, at least for me, a time constraint.

But John is right, what I really need is a complete script that is sort of plug in play, something I'll just need to put in the location of my sample clip into, and/maybe add some more plug-ins into, etc. to get it to do its thing. I hope my initial post here made that clear.

Bruce/Fl
3rd September 2015, 17:48
@Bruce/Fl

Post a sample for everyone.



I'll work on doing just that tonight.

How much (length) of a sample would be best? Taking file size into consideration. The sample scan they sent me was approximately 10 minutes. I would assume you would only need 10, 15 seconds worth?

Thank you

Bruce

StainlessS
3rd September 2015, 17:52
halfblksize= (block_size>4) ? block_size/2 : 4
halfoverlap= (block_over>2) ? block_over/2 : 2



John, would below be more like what you require ?


halfblksize= (block_size/2>4) ? block_size/2 : block_size
halfoverlap= (block_over/2>2) ? block_over/2 : block_over


If no difference from original sizes, would MRecalculate be necessary ?

EDIT: Oops, maybe below better


halfblksize= (block_size/2 >= 4) ? block_size/2 : block_size
halfoverlap= (block_over/2 >= 2) ? block_over/2 : block_over

feisty2
3rd September 2015, 18:06
All same stuff
John's version
Blksize > 4 (blksize=8, 16, 32), then halve it, if not (blksize =4), keep it 4
Your version
1: buggy, say blksize =8, and you know what will happen
2: = John's version blksize/2>=4 ---> blksize>=8---->blksize>4, If not, then obviously blksize=4, and ":blksize"=":4"

StainlessS
3rd September 2015, 18:14
Cant remember off hand if block sizes have to be a power of 2.

What about MRecalculate thing feisty ?

EDIT: yes 1. was buggy.

feisty2
3rd September 2015, 18:24
Recalculate is meant for, not just different, actually smaller block size, the vector clip contains 3 things of each vector, vx, vy and thsad, recalculate reads the thsad from one vector, and if it's too high, then the block is kind of "high energy" (complicated) or whatever and the motion estimation is bad and recalculate will divide the large block into 4 smaller blocks and try to match again, so you'll always have the most precise match

StainlessS
3rd September 2015, 18:27
Yeh but, if sizes aint smaller, then is there any point at all in calling MRecalculate, is it a NOP, or just a time waster ?

(Or does it actually still do something useful)

feisty2
3rd September 2015, 18:29
If the recalculate blksize >= analyze blksize ------> waste of time

StainlessS
3rd September 2015, 18:32
Thank you F, then my initial post was perhaps not also a total waste of time.

johnmeyer
3rd September 2015, 18:38
We're off on a tangent here. The block size and MRecalculate were an attempt to get a slight improvement in speed and quality, and that's exactly what I got: a slight improvement. The code I posted was just lifted directly from the MVTools2 documentation.

And, speaking of documentation, I'm still trying to figure out this statement:

thSAD ain't no "denoising_strength"... like, really not, way not
I know cuz I just read the code of mvtools and wrote my own ultra high precision (32bits float) branch
thSAD is like, more of the tolerance of imperfect motion estimation, larger thSAD = messed up motion vectors with lots of errors would still be, like, okay, acceptable and join the process
the real strength of MDegrain is "tr", larger tr = higher strength First of all, "tr" was not a part of MVTools2 until version 2.6.x, and I'm still using 2.5.x.

Second, in reading the 2.6.x documentation, "tr" is not used in their sample degraining code, so the authors did not think it important. Here is that code, copied directly from the documentation:

To denoise interlaced source with function MDegrain2i2:

function MDegrain2i2(clip source, int "overlap", int "dct")
{
overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
dct=default(dct,0) # use dct=1 for clip with light flicker
fields=source.SeparateFields() # separate by fields
super = fields.MSuper()
backward_vec2 = super.MAnalyse(isb = true, delta = 2, overlap=overlap, dct=dct)
forward_vec2 = super.MAnalyse(isb = false, delta = 2, overlap=overlap, dct=dct)
backward_vec4 = super.MAnalyse(isb = true, delta = 4, overlap=overlap, dct=dct)
forward_vec4 = super.MAnalyse(isb = false, delta = 4, overlap=overlap, dct=dct)
fields.MDegrain2(super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400)
Weave()
}

AVISource("video.avi")
mdegrain2i2(4,0)


Finally, "tr" really is not a very practical denoising variable, since it can only take on a few discrete values (0 through 5 is the extent of the practical range). Most desnoising scripts, like this one:

http://forum.doom9.org/showpost.php?p=1714954&postcount=2

use the tr variable as more of a switch than a denoising setting. So, yes, it can be included as a way to change the nature of the denoising, but I certainly wouldn't call it a "strength" variable.

thSAD isn't exactly a strength variable either, but it does continuously (rather than discretely) change the nature of the denoising, and is the best setting this function offers for changing the amount of denoising.


Note to the OP: the code above is what you might want to use if you are using the latest version of MVTools2. Just change the AVISource statement to whatever you use to read your MOV video, and then see what the result looks like.

feisty2
3rd September 2015, 18:51
What..? tr and thsad are 2 100% different and irrelevant things, you can't just say, like, one is continuous and one is discrete
Man, you can't even compare these two
They are just like... Apples and oranges...

johnmeyer
3rd September 2015, 19:09
What..? tr and thsad are 2 100% different and irrelevant things, you can't just say, like, one is continuous and one is discrete
Man, you can't even compare these two
They are just like... Apples and oranges...Irrelevant to what?? thSAD is completely relevant to any discussion of using MDegrain2 for denoising.

As for your other statement, I totally agree that tr and thSAD are completely different. But I was not, in any way, "comparing" them.

So, I don't understand at all what you are trying to say. What is your point?? Also, how are you trying to help the OP (and anyone else) achieve better degraining results?

feisty2
3rd September 2015, 19:13
I was just trying to get that misunderstanding about "thsad" as denoising strength straight
Thsad is not the strength of denoising
It's the strength of error tolerance of motion estimation

johnmeyer
3rd September 2015, 19:18
I was just trying to get that misunderstanding about "thsad" as denoising strength straight
Thsad is not the strength of denoising
It's the strength of error tolerance of motion estimationI agree. I also agree that it does not provide ideal control over denoising. Unfortunately, the way the code is written, and given the variables that are exposed to the user, it is pretty much all we have.

johnmeyer
3rd September 2015, 21:10
How much (length) of a sample would be best? Taking file size into consideration. The sample scan they sent me was approximately 10 minutes. I would assume you would only need 10, 15 seconds worth?5-10 seconds, preferably something with motion (i.e., static shots of a building are not as useful as something where people are walking or cars are driving by, etc.).

Bruce/Fl
3rd September 2015, 22:24
This should be about 6 seconds of my sample. Here is the link. I used Vegas, rendered it as .m2ts

https://www.dropbox.com/s/wpgso9p8awqi3gq/Upload.m2ts?dl=0

johnmeyer
3rd September 2015, 23:30
Wow, that is really grainy. As a result, any attempt to use VideoFred's script will result in a fine mess because his scripts do quite a bit of sharpening. Sharpening grain, even after "degraining" is going to produce bad results. In fact, this is one of the main things that drove me to create my version of his script. If you click on the link below, you can see my post in his original film restoration thread -- complete with several images -- that shows the problems his original script created with my grainy footage:

The power of Avisynth: restoring old 8mm films (http://forum.doom9.org/showpost.php?p=1405197&postcount=208)

Also, when you actually do the work, make sure to work with the original MOV. This sample you uploaded has been recompressed using the Sony AVC codec, and there are a lot of additional artifacts added to the grain.

Finally, if this clip really accurately represents the original (i.e., you didn't screw up when you rendered it), then you need to decimate half the frames before you do any degraining. This is because the frames are all duplicated, and the degraining will choke when it sees zero motion between half of the frames.

Here is the script I just used on your clip. I frameserved it from Vegas, which is what I always do in order to avoid having to figure out how to read dozens of different formats into AVISynth. I let Vegas do that job because uses professional codecs that seldom glitch or fail. Note the "selecteven()" statement in the first line. This gets rid of every other frame, thus eliminating all the duplicates. The Assumefps statement gets you back to the correct playback speed.

So, you will need to replace the AVISource() statement with whatever you have found works for getting your MOV files into AVISynth. As I remember from our PMs last week, you did figure that out and got it working.

Hopefully other people will provide some additional ideas. I'm sure they will be glad to critique my work :)

source=AVISource("e:\fs.avi").selecteven()
super = MSuper(source,pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=1400)
final=assumefps(15/1.001)
return final
#stackhorizontal (source,final)

Bruce/Fl
4th September 2015, 00:44
This sample you uploaded has been recompressed using the Sony AVC codec, and there are a lot of additional artifacts added to the grain.


Does anyone here know if Vegas can trim a .mov clip losslessly, or if not, what is the best option for rendering a .mov file? I tried the quicktime 7 (.mov) options, but even to my eye they looked very splotchy. (<---- ya, my word)

Or possibly some other program? I'd love for these samples I'm uploading to be simply shorter versions with the same quality as what I received.

Thank you,

Bruce

johnmeyer
4th September 2015, 01:34
Use Mediainfo or similar tool to find out what codec is used by the MOV file. Vegas may give this to you if your right-click on the media and select "properties."

In general, Vegas does not "smart render" (a.k.a., lossless cuts) most video. It can smart render DV AVI and some forms of MPEG-2, but that's about it.

Having said that, if the version of ProRes (I think that's what you said this is) does not do interframe compression, Vegas may well be able to render it losslessly.

It is easy to tell: just start the render and watch the preview screen in Vegas while rendering. If the video is not being re-rendered, the display will show "no compression needed."

Did my script work for you?

Bruce/Fl
4th September 2015, 03:51
Use Mediainfo or similar tool to find out what codec is used by the MOV file. Vegas may give this to you if your right-click on the media and select "properties."

In general, Vegas does not "smart render" (a.k.a., lossless cuts) most video. It can smart render DV AVI and some forms of MPEG-2, but that's about it.

Having said that, if the version of ProRes (I think that's what you said this is) does not do interframe compression, Vegas may well be able to render it losslessly.

It is easy to tell: just start the render and watch the preview screen in Vegas while rendering. If the video is not being re-rendered, the display will show "no compression needed."

Did my script work for you?

No, it said "Avisynth open failure, there is no function named "MSuper" "

I also linked it to a .avi render I did, so that it would work with what you gave me as written.

Attached are the media info screen caps from the original .mov and also my AVC render, just because.

This is because the frames are all duplicated, and the degraining will choke when it sees zero motion between half of the frames.

I was curious about this, after reading your explanation about how the degraining process worked, when I suspected that I did have duplicate frames. The reason I suspected that was, when I was trying to find the first frame of a scene in Vegas, using the frame advance button, it always seemed like I needed to click it twice to see any change in the image.

johnmeyer
4th September 2015, 04:44
No, it said "Avisynth open failure, there is no function named "MSuper" "You have to put the MVTools2 DLL in your AVISynth plugins folder.

Bruce/Fl
4th September 2015, 05:16
You have to put the MVTools2 DLL in your AVISynth plugins folder.

It is now in there, now it says: "MSuper: Clip must be YV12 or YUY2

Attached is the media info on the avi. It's huge, it's 4:2:2 and it says it's lossless.

I can probably uplaod it if you'd like to see it, better quality than the m2ts maybe?

StainlessS
4th September 2015, 05:54
Bruce/Fl,

You can just copy and paste MediaInfo text into post, click 'Go Advanced', and then select text and click on the Hash symbol above the post entry box, it can take a long time for attachments to clear approval.

You can see what colorspace Avisynth thinks clip is by pasting


Return Info.ConvertToRGB32

immediately after the line that loads the clip.

raffriff42
4th September 2015, 07:36
And here's some help for cutting down that huge source file. (http://forum.doom9.org/showthread.php?t=172557)

Bruce/Fl
4th September 2015, 16:33
And here's some help for cutting down that huge source file. (http://forum.doom9.org/showthread.php?t=172557)

That worked great, thank you so much for that.

Now I'll upload a few seconds of the original, for anyone wanting to see it un-reencoded.

Bruce

Bruce/Fl
4th September 2015, 16:43
Here is a sample in the original format, .mov


https://www.dropbox.com/s/2xk8v5r36en6hss/Sample8mm_1.mov?dl=0

Bruce/Fl
4th September 2015, 16:56
Bruce/Fl,

You can see what colorspace Avisynth thinks clip is by pasting


Return Info.ConvertToRGB32

immediately after the line that loads the clip.

I added it. Now it says, "I don't know what "info" means"

And just to be sure there are no mistakes I've made, here is what I have writtin:

source=AVISource("C:\Users\Bruce\Desktop\upload.avi").selecteven()
Return Info.ConvertToRGB32
super = MSuper(source,pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=1400)
final=assumefps(15/1.001)
return final
#stackhorizontal (source,final)

videoFred
4th September 2015, 17:21
It is now in there, now it says: "MSuper: Clip must be YV12 or YUY2

Avisynth is telling you that MSuper requires YV12 or YUY2 colorspace. How to fix this? By changing color space from the input of cource.

Change your first line like this:
source=AVISource("C:\Users\Bruce\Desktop\upload.avi").selecteven().converttoYV12()


Fred.

Bruce/Fl
4th September 2015, 17:47
Avisynth is telling you that MSuper requires YV12 or YUY2 colorspace. How to fix this? By changing color space from the input of cource.

Change your first line like this:
source=AVISource("C:\Users\Bruce\Desktop\upload.avi").selecteven().converttoYV12()


Fred.

Thanks Fred, that got rid of the trouble boxes, and I have an image in virtualdub now. A very large image, but an image, and it moves, slowly.

Unfortunately I have to run now, but will return to this later today and see what I can do/see.

Again, thanks all.

Bruce

Boulder
4th September 2015, 19:08
Based on my experiences, you definitely want to preclean the clip you analyse motion from if the amount of noise or grain is extreme. I'd try FFT3DFilter or some of those NLMeans-type denoisers.

StainlessS
4th September 2015, 23:17
I added it. Now it says, "I don't know what "info" means"

And just to be sure there are no mistakes I've made, here is what I have writtin:

source=AVISource("C:\Users\Bruce\Desktop\upload.avi").selecteven()
Return Info.ConvertToRGB32


Arh, OK, you assigned clip to source variable, so I should have posted:

return source.info.ConvertToRGB32


instead.
I assumed that you have not assigned to any named variable and so would have been assigned to the special 'implied' Last clip variable.

What I originally posted was equivalent to this:

AVISource("C:\Users\Bruce\Desktop\upload.avi").selecteven() # Implied assignment to special Last variable.
return Last.info.ConvertToRGB32
# return info.ConvertToRGB32 # EDIT: Or use implied Last without explicit naming


JFYI.

mawen1250
5th September 2015, 04:09
About thSAD, from what I have read before(just a glance at the mvtools code):
It actually affacts the denoising strength of MDegrain, since MDegrain weighted average the matched blocks, and the weighting is calculated from SAD and thSAD. Thus, a higher thSAD results in dissimilar blocks to have larger weight, and it can increase denoising strength as well as introduce more blending artifacts.
As for MCompensate based denoising, thSAD might just be a threshold to determine bad matches.

feisty2
5th September 2015, 04:33
inline float DegrainWeight(double thSAD, double blockSAD) {
if (blockSAD >= thSAD)
return 0.f;

return float((thSAD - blockSAD) * (thSAD + blockSAD) * 256 / (thSAD * thSAD + blockSAD * blockSAD));
}



if (blockSAD >= thSAD)
return 0.f;

threshold

weight = 256 * (thSAD^2 - blockSAD^2) / (thSAD^2 + blockSAD^2)
you got thSAD at both multiplication and division part, who knows what will happen to the weight if you increase it, not doing a monotonicity determination of "y = (x^2 - a)/(x^2 + a)" here

feisty2
5th September 2015, 05:06
well... I just did it anyways, cuz that's just some 15 years old simple math
turns out "y' = 4ax / (x^2 + a)^2", and y' always > 0
so, guess mawen1250's right, you increase the weight by increasing thSAD

EDIT:
but that doesn't really matter, you know, it's an "x/x^4" kinda thing... it grows really, really, really, slow, yeah, you know what I mean....

feisty2
5th September 2015, 05:46
So, theoretically, thSAD affects the weight a little little little bit, but, practically, it's just a threshold of motion estimation

Boulder
5th September 2015, 06:38
Thsad is definitely the parameter to control the strength of the denoising. There's also the limit parameter that can be used to limit the amount of change.

Usually thsad=400 already results in quite heavy smoothing, but that naturally depends on the motion vectors of the analyse clip. If that clip is precleaned, you need to apply a lower thsad to get the same level of denoising.

feisty2
5th September 2015, 06:44
Well, it's a threshold, sure it would do something to the denoising result, larger thSAD=more blocks will join the average process
But it almost does nothing to the weight, so that's not what you call it, "strength"
No, not strength
It's the error tolerance of motion estimation

raffriff42
5th September 2015, 06:52
Will the debating never end? While waiting for a final answer from the smart people here,
I have cobbled together something around my old pal QTGMC that seems to work.
There is still room for improvement: it might be too flat overall, and little artifacts crawl around the edges.
But with such a high grain level, this is the 'best' result possible (...or is it?)

EDIT Boulder (post #46 (http://forum.doom9.org/showthread.php?p=1737268#post1737268)) has a point - in fact, I think I prefer to see the original grain, after all ...
but keep the cropping, speed and color correction.

EDIT I see an objectionable fixed, or semi-fixed, noise pattern with all degrain methods I've tried,
(DeGrainMedian, SMDegrain, MDegrain2, Deen, KNLMeansCL, even QTGMC) when set strong enough for this source.

So I overlayed a little of the unprocessed video, with all its graininess, to break up the fixed pattern.
The results are good IMHO - at least on the short sample.

https://www.dropbox.com/s/19jsxzmynl507kc/Degraining%20script%20assist%20Sample-frm79-crop-frm80-00-org.jpg?raw=1
input, cropped

https://www.dropbox.com/s/ck4mvkfmlufiwdv/Degraining%20script%20assist%20Sample-frm79-crop-QTGMC-10%20%2810%2B0-0.5d%29%2Blvls24.jpg?raw=1
It's hard to tell from a static image, but what you see now are "fast moving" dark specks
instead of "fixed" or "slowly swimming" noise. Here is the video (2.7 MB) (https://dl.dropboxusercontent.com/u/108089426/Video_temp/Sample8mm_1%7EQTGMC-12%20rsz2%20%283%2B0-0.4d%29%2Blvls24%2Bwb%20vx28.mp4)

# http://avisynth.nl/index.php/QTGMC
#Import("QTGMC\QTGMC-3.32.avsi")

# http://avisynth.nl/index.php/FFmpegSource
# http://avisynth.nl/index.php/LSMASHSource
FFVideoSource(sourcefile, enable10bithack=1>0)
#LSMASHVideoSource(sourcefile, format="YUV422P16", stacked=true)
## choose either source plugin

## eliminate repeating frames (new framerate 14.98)
SelectEven

## pillarboxes
Crop(240, 0, -240, 0)

## denoise in 10-bit & convert to 8-bit
## http://avisynth.nl/index.php/Dfttest
#dfttest(sigma=64.0, tbsize=1, lsb_in=true, lsb=false) ## (strong denoising)
dfttest(sigma=6.0, tbsize=1, lsb_in=true, lsb=false) ## (weak denoising)
ConvertToYV12

Overlay(
\ BilinearResize(Width/2, Height/2)
\ .QTGMC(InputType=1, Preset="Placebo", EZDenoise=3.0)
\ .Spline64Resize(Width, Height),
\ Last, opacity=0.4, mode="darken"
\ )

## raise gamma (for preview only - it's better to color-correct in your video editor)
#Levels(16, 1.55, 235, 16, 235)
## SmoothLevels looks noticeably better
# http://forum.doom9.org/showthread.php?t=154971
LoadPlugin("SmoothAdjust.dll")
SmoothLevels(20, 1.3, 210, 16, 235)

## playback speed too fast - adjust it by eye (for preview only)
AssumeFPS(11)

return Last

Boulder
5th September 2015, 06:53
Maybe so, but it basically is the thing you need to use to control the result.

The docs do mention that the blocks with lowest SAD have the highest weight.

EDIT: replying to feisty

Boulder
5th September 2015, 06:55
Out of interest:why degrain heavily? The grain makes the result appear sharper than it is.

feisty2
5th September 2015, 07:03
Maybe so, but it basically is the thing you need to use to control the result.

The docs do mention that the blocks with lowest SAD have the highest weight.

EDIT: replying to feisty

Block sad comes from the vector clip, a in the "y=(x^2-a)/(x^2+a)", we are talking about thSAD parameter of MDegrain, which is "x", not "a"

Bruce/Fl
5th September 2015, 08:18
Riffraff42, pretty cool to see it with some results. Thank you for looking into this also. To my eye, FWIW, it looks like too much grain was removed in this case, but cool to see that it can be affected in that way.

I'm curious as to why there is so much graininess. Until John Meyer finally got to see what I was working with and confirmed my thoughts about the grain being somewhat excessive, I kind of convinced myself that maybe it was just the nature of the beast, that when you blow up an image on a, in my case 23" diagonal monitor, and you are starting out with only an 8mm source, well, you're gonna see every flaw.

My father took the film, I was the 7 year old in the image, so I had no idea, and didn't even think about or care about the ISO of the film he used, or anything, he was simply taking movies to me.

So I wonder if it was the film selected, the initial processing, or maybe the lenses on the camera, which was some model of a Keystone.

He's not here to ask anymore, so I will just have to wonder.

Bruce/Fl
5th September 2015, 08:23
Now that I had a functional script, I was practicing working with Vegas, the frameserver, and getting it back when I noticed I needed VAPIConv to complete that process. So I downloaded it, read the tutorial here (http://www.doom9.org/index.html?/mpg/vfapi_reader_codec.htm) and as I tried to run "proxyoff.reg" from the VDub subfolder, it failed, saying "Cannot import C:\Users\xxx.............xxx\proxyoff.reg: Not all data was successfully written to the registry. Some keys are open to the system or other processes."

I wasn't sure if my having Virtual dub running, or any ot the other affiliated programs possibly running was messing with it, so I did a hard reboot, deleted everything VAPIConv related, and tried again with only chrome running to get the download again and read the tutorial. I got the same trouble message.

Anybody run into this before? I can't get VAPIConv to work properly without this successfully loading.

raffriff42
5th September 2015, 08:24
I'm curious as to why there is so much graininess...High speed film = no worries about lighting but tons of grain. N00b photographer's mistake (been there)