Log in

View Full Version : mdegrain3 (old mvdegrain3) and x265 10 bit


cool advertise
21st September 2018, 03:13
Hello someone who knows, can show me the complete avisynth script (including the loading of plugins) for use the old mvdegrain3 with x265 10 bit (2160p) as output with megui and avisynth+?
In megui I use "always use the included avisynth" in the settings, under main configuration, and i use "development update server".
I always use the one-click encoder button to make the encoding.

With old 1080p source and x264 i used this script, and it did a great job on video with grain, but it don't works with x265 10 bit...



LoadPlugin("C:\My path\filters\mvtools.dll")
LoadPlugin("C:\My path\filters\mvtools2.dll")

last = isRGB(last) ? ConvertToYV12(last) : last
last = isYUY2(last) ? ConvertToYV12(last) : last

backward_vec3 = last.MVAnalyse(isb = true, delta = 3, pel = 2, overlap=2, sharp=1, idx = 1)
backward_vec2 = last.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=2, sharp=1, idx = 1)
backward_vec1 = last.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=2, sharp=1, idx = 1)
forward_vec1 = last.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=2, sharp=1, idx = 1)
forward_vec2 = last.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=2, sharp=1, idx = 1)
forward_vec3 = last.MVAnalyse(isb = false, delta = 3, pel = 2, overlap=2, sharp=1, idx = 1)
last.MVDegrain3(backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=300,idx=1)


Thanks for any help, there are not many explanations about this subject

StainlessS
21st September 2018, 04:15
You are not gonna get old mvtools (long time before 10 bit implemented), to work on 10 bit.

Here function using new mvtools (I dont use high bit depth but so long as you use recent Pinterf mvtools2, you should be good to go).

MCDeGrain.avsi # putin plugins dir, also put mvtools2 in plugins.

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)
}



Avisource("...")
McDegrain(3)


EDIT: I kinda like this one, use it almost all of the time

Function MCDegrainSharp(clip c, int "frames", float "bblur", float "csharp", bool "bsrch",bool "Precise") {
# From:- http://forum.doom9.org/showthread.php?p=1737045#post1737045
# Based on MCDegrain By Didee, http://forum.doom9.org/showthread.php?t=161594
# Also based on DiDee observations in this thread: http://forum.doom9.org/showthread.php?t=161580
# "Denoise with MDegrainX, do slight sharpening where motionmatch is good, do slight blurring where motionmatch is bad"
# In areas where MAnalyse cannot find good matches, the blur() will be dominant.
# In areas where good matches are found, the sharpen()'ed pixels will overweight the blur()'ed pixels
# when the pixel averaging is performed.
#
# Mod by StainlessS to add Precise, 3 Sept 2015.
frames = default(frames, 2)
bblur = default(bblur, 0.6)
csharp = default(csharp, 0.6)
bsrch = default(bsrch, true)
Precise=Default(Precise,False) # Use MRecalculate
bs = (c.width>960) ? 16 : 8
c2 = c.blur(bblur)
super = bsrch ? c2.MSuper(pel=2, sharp=1) : c.MSuper(pel=2, sharp=1)
super_rend = c.sharpen(csharp).MSuper(pel=2, sharp=1,levels=1) # Only 1 Level required for sharpened Super (not MAnalyse-ing)
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)
# If Precise, then recalculate on Prefiltered (blurred) Super (NOT the sharpened render super)
backward_vec3 = (Precise) ? MRecalculate(super, backward_vec3, blksize=bs/2, overlap=bs/4,thSAD=100) : backward_vec3
backward_vec2 = (Precise) ? MRecalculate(super, backward_vec2, blksize=bs/2, overlap=bs/4,thSAD=100) : backward_vec2
backward_vec1 = (Precise) ? MRecalculate(super, backward_vec1, blksize=bs/2, overlap=bs/4,thSAD=100) : backward_vec1
forward_vec1 = (Precise) ? MRecalculate(super, forward_vec1 , blksize=bs/2, overlap=bs/4,thSAD=100) : forward_vec1
forward_vec2 = (Precise) ? MRecalculate(super, forward_vec2 , blksize=bs/2, overlap=bs/4,thSAD=100) : forward_vec2
forward_vec3 = (Precise) ? MRecalculate(super, forward_vec3 , blksize=bs/2, overlap=bs/4,thSAD=100) : forward_vec3
#
(frames<=0) ? c :\
(frames==1) ? c2.MDegrain1(super_rend, backward_vec1,forward_vec1,thSAD=400) :\
(frames==2) ? c2.MDegrain2(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) \
: c2.MDegrain3(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=400)
return(last)
}



AviSource("...")
MCDegrainSharp(1)

FranceBB
21st September 2018, 04:46
Uh...
I know you won't like the reply, but I suggest you not to use MeGUI and to use Avisynth+ and x265.
Besides, pinterf updated MVTools and he did a great job!
The new mvtools support to high bit depth 10-32bit on Avisynth+.

Anyway, if you wanna stick with MeGUI and Avisynth 2.6.1, there are two things you should consider:

1) MVDegrain3 doesn't support normal high bit depth, but it does support 16bit stacked.
2) I think that you are running out of memory with UHD contents.

In order to achieve that, I would split these calcs into multiple processes, so that each process can allocate 2GB of RAM each.

Something like this in Avisynth 2.6.1 would probably do what you need:


MP_Pipeline("""
#Indexing 10bit content by outputting 16bit stacked
FFVideoSource("video.m2ts", enable10bithack=true)
s16=last

### platform: win32
### export clip: s16
### ###

#Dither down to 8bit for MAnalyse only
bit8=s16.DitherPost(mode=-1)
### platform: win32
### export clip: s16, bit8
### ###

#Analysing at 8bit
backward_vec3 = bit8.MVAnalyse(isb = true, delta = 3, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3
### ###

backward_vec2 = bit8.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3, backward_vec2
### ###

backward_vec1 = bit8.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3, backward_vec2, backward_vec1
### ###

forward_vec1 = bit8.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3, backward_vec2, backward_vec1, forward_vec1
### ###

forward_vec2 = bit8.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3, backward_vec2, backward_vec1, forward_vec1, forward_vec2
### ###

forward_vec3 = bit8.MVAnalyse(isb = false, delta = 3, pel = 2, overlap=2, sharp=1, idx = 1)

### platform: win32
### export clip: s16, bit8, backward_vec3, backward_vec2, backward_vec1, forward_vec1, forward_vec2, forward_vec3
### ###

#Degrain at 16bit stacked using 8bit vectors
s16.MVDegrain3(lsb=true, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=300,idx=1)

### platform: win32
### ###
""")

#Note that the output will be in 16bit stacked and it's gonna be up to x265 to dither it down to 10bit and encode.


This way you'll be able to do post-processing at 16bit stacked (high bit depth), preserving the quality of your 10bit source and the process will happen in 9 different process, so Avisynth will be able to allocate 18 GB of RAM (2GB x 9).

Not exactly the ideal solution, though.
I strongly suggest you to drop MeGUI, switch to Avisynth+, update MVTools with the ones provided by Pinterf and use x265 via command line: it's gonna be faster, more updated and easier to use.
And, for the records, the script would be way shorter to do the same things.

cool advertise
21st September 2018, 07:35
Thanks guys, you have the knowledge.
I did a quick test and it is very slow for 2160p video in x265, while for 1080p, and x264 video, the speed was acceptable.
I do not think I will use it a lot.

EDIT (Final review after several test):
McDegrain(3) is too slow for content in x265 10 bits at 2160p, I will not use it.
Instead I found a good and decent speed with McDegrain(2).
I will use the latter.