Go Back    Forum > Digital Video > Video Project Help > Restore, Filter, Improve Quality

Reply
 
LinkBack Thread Tools
  #41  
05-01-2018, 05:48 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Ok I understand & thanks for the Neuron2.

Quote:
Originally Posted by sanlyn View Post
New general script:

Code:
Import("Drive:\path\to\Avisynth plugins\MDG2.avs")
Import("Drive:\path\to\Avisynth plugins\RemoveDirtMC.avs")

aud=NicMPG123Source("E:\forum\faq\yukukuhi\B\"
  \+"Chinnvar Movie Comedy Sample PID 125 L2 2ch 48 256 DELAY 5ms.mp2",
  \normalize=false)
vid=MPEG2Source("E:\forum\faq\yukukuhi\B\"E:\forum\faq\yukukuhi\B\"
  \+"Chinnvar Movie Comedy Sample.d2v")
AudioDub(vid,aud)

Source1=last
a=source1.SelectEvery(3,0).RemoveDirtMC(50,false).RemoveSpotsMC2().MDG2()
b=source1.SelectEvery(3,1).RemoveDirtMC(50,false).RemoveSpotsMC2().MDG2()
c=source1.SelectEvery(3,2).RemoveDirtMC(50,false).RemoveSpotsMC2().MDG2()
Interleave(a,b,c)

LimitedSharpenFaster()
AddGrainC(1.5,1.5)
return last
And can this above script you posted on post #32 of this thread, be used on sources with high or even minimal noises for that matter to avoid the introduction of artifacts in the video.

Last edited by yukukuhi; 05-01-2018 at 06:04 AM.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #42  
05-01-2018, 06:25 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
There is no one-size-fits-all procedure for all videos. The routines shown were for digital sources with film scratches.

I've recorded thousands of cable broadcasts with DVD recorders and HD-PVRs. I never had to filter any of them.
Reply With Quote
  #43  
05-01-2018, 11:07 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Ok then i'll come to you when i have trouble restoring videos by posting in this forum.

And is it okay with you if i ask questions every now and then for clarification.

P.S. I still got lots to learn from everyone.
Reply With Quote
  #44  
05-01-2018, 12:22 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
If you run into different video problems or have questions, feel free to post in the forum.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-02-2018)
  #45  
05-02-2018, 06:48 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Ok I'll do that.

And sanlyn, now that I've got a clear understanding of your first step of restoration guidelines of running histograms & stuffs for correcting major level and colour correction that you'd expressed on post #23 and post#27 of this thread also including the link to the Encoding from Huffyuv? thread that you had shared as well in the same post which had covered them in detail starting from it's post #7, could you be able to continue sharing your next step of restoration which would obviously be denoising.

I've had gone through quite some knowledge of denoising video contents which I had happen to read in a guide of AMV website titling Improving Visual Quality with AviSynth Filters. But it focuses only on Anime only and not on film stuffs.

So for first & foremost it would be beneficial to explain for me and others who are, or were following up till now that on how to analyse and figure out the noises that would be present in a film footage. Also of applying the appropriate filters for removing them as well without introducing artifacts. Please share.
Reply With Quote
  #46  
05-02-2018, 12:18 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
All of the filters discussed in the AMV guide you reference can be used on any kind of video. As for noise removers, the filters used in earlier scripts -- RemoveDirt, RemoveSpots, and the MDegrain2 filter in DGM2 are all noise removers of one kind or other. There are a few dozen other Avisynth plugins for various tasks listed here, which include the filters discussed at AMV: http://avisynth.nl/index.php/External_filters. Many of them have been used in hundreds of restoration threads here as well as in the projects I linked earlier. A recent denoising example from a few days ago: http://www.digitalfaq.com/forum/vide...storation.html which includes use of a few filters listed on AMV. Many AMV filters are also used as support files for other major plugins; LSFmod, deblock variants, and gradfun2DBmod are used in MCTemporalDenoise, dfttest is used as a denoiser in QTGMC, and so on.

Ordinarily digital broadcasts of film originals don't have much noise, with the exception of compression artifacts and bad color that might be present during the transfer process. If you're talking about film transfers from India, most believe they are purposely screwed up to prevent pirating (as if that stops pirating, right?). Most of the problems with those transfers are badly designed frame re-structuring and resizing errors. If you want to see some real noise problems, try VHS capture and restoration threads in this and other forums. Examples of truly awful noise and compression artifacts can be seen anywhere on YouTube, where most of the noise is due to low bitrate encoding and to typical mistakes by users, and very little of it can be repaired.

Last edited by sanlyn; 05-02-2018 at 12:30 PM.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-03-2018)
  #47  
05-03-2018, 03:17 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
I get it. And while i read through the forums, i'll get hold of some video samples that i've with different noises present in them with varying intensity & post them in this forums for getting an even more understanding of removing noises.

Btw, could you explain this earlier script below that you've posted in post#12 of this thread in detail of what you were doing.

Script 1: Chinnvar_01_25p.avs
Code:
## --- modify the path statements below to match your system --- ##
aud=ffaudioSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
vid=ffvideoSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
AudioDub(vid,aud)

## --- The line below is a comment. Remove the # character to execute the code. --- ##
## --- If working with the YUY2 original, the code converts to YV12 color. -------- ##
# ConvertToYV12(interlaced=true)  

AssumeTFF()
SeparateFields()
Source=last
a=source1.SelectEvery(3,0).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
b=source1.SelectEvery(3,1).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
c=source1.SelectEvery(3,2).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
Interleave(a,b,c)
LimitedSharpenFaster()
AddGrainC(1.5, 1.5)
AssumeFieldBased()
Weave()
return last
### --- Save with Lagarith as YV12 --- ###

#..........................................................................................
### --- REMOVE DIRT & REMOVE DIRT MC FUNCTIONS --- ###
### --- -------------------------------------- --- ###
### --- Required: RgTools.dll & RemoveDirt.dll --- ###

function RemoveDirt(clip input, int "limit", bool "_grey")
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=30,cthreshold=8,\
     gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)

  # Alternative settings
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6,\
  #  gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8,\
  #  gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,\
  #  grey=_grey,show=false)
}

function RemoveDirtMC(clip, int "limit", bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

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

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=20)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=20)

  backw = MFlow(clip,super,bvec_re,thSCD1=900,thSCD2=200)
  forw  = MFlow(clip,super,fvec_re,thSCD1=900,thSCD2=200)

  clp=interleave(forw,clip,backw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}


#..........................................................................................
function MV2(clip)
{ 
### --- copy of modified MDeGrain2 MVTools filter, renamed "MV2" ---- ###
### --------- (requires MVTools2.dll and aWarpSharp.dll)  ----------- ###
source=clip

  super = source.MSuper(pel=2, sharp=1)
  backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=8, overlap=4, dct=0)
  backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=8, overlap=4, dct=0)
  forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=8, overlap=4, dct=0)
  forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=8, overlap=4, dct=0)
  MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400) 

    clean=last #save cleaned version
    diff1=subtract(source,clean).Blur(0.25)
    diff2=diff1.blur(1.5,0)
#diff3 is high-ish frequency noise only
    diff3=subtract(diff1,diff2) 
#sharpen cleaned version a little
    sharpen(0.3,0.0) 
#mix high frequency noise back in
    overlay(last,diff3.levels(128,1.0,255,0,127,coring=false),mode="add", opacity=0.7)
    overlay(last,diff3.levels(0,1.0,127,128,255,coring=false).Invert(),mode="subtract", opacity=0.7)
#put cleaned chroma back in with warp sharpening
    mergechroma(clean.aWarpSharp(depth=20.0, thresh=0.75, blurlevel=2, cm=1))

return last}
Reply With Quote
  #48  
05-04-2018, 04:23 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
What I wasn't able to understand was the functions parameter that you've mentioned in the script and also of why you didn't added them in the new general script.

What was the notion in putting them in the script?

Could you explain it.
Reply With Quote
  #49  
05-04-2018, 07:37 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by yukukuhi View Post
What I wasn't able to understand was the functions parameter that you've mentioned in the script and also of why you didn't added them in the new general script.

What was the notion in putting them in the script?
I posted the full text of RemoveDirtMC and MV2 functions in the first script because they were new to most readers. They are in fact most often used as imported .avs scripts. Using the Import() function pulls in the full text of the function definition, which includes the list of parameters.

As a side note, even when you have the parameter list you still don't know what some of the parameters mean or what the accepted value range would be. You need some documentation on that. Most Avisynth plugins ship as packages with html documentation or readme files. It so happens that the more popular versions of RemoveDirtMC and MV2 (aka MDG2) used in this thread are hand-me-down versions from Doom9 authors who created more abbreviated and convenient versions of the original plugins but didn't pass along the original documentation.

Rather than blindly download plugins, whether Avisynth or Virtualdub, it's a good idea to look over the package for any documentation or runtime notes. Sometimes instructions are brief notes inside an avs or avsi script, which you can read in Notepad. Often the really long scripts like QTGMC were created in MS-DOS Text with Formatting, which you have to open in Wordpad or Microsoft Word. A filter with a ton of documentation is QTGMC. It comes with a long html and the avsi script itself in MS-DOS Formatted text, is over 963 lines, iof which about 200 lines at the top of the script is extensive text and tables. QTGMC has over 85 parameters.

Quote:
Originally Posted by yukukuhi View Post
Btw, could you explain this earlier script below that you've posted in post#12 of this thread in detail of what you were doing.

Script 1: Chinnvar_01_25p.avs
Code:
## --- modify the path statements below to match your system --- ##
aud=ffaudioSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
vid=ffvideoSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
AudioDub(vid,aud)

## --- The line below is a comment. Remove the # character to execute the code. --- ##
## --- If working with the YUY2 original, the code converts to YV12 color. -------- ##
# ConvertToYV12(interlaced=true)  

AssumeTFF()
SeparateFields()
Source=last
a=source1.SelectEvery(3,0).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
b=source1.SelectEvery(3,1).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
c=source1.SelectEvery(3,2).RemoveDirtMC(50,false).Descratch().TurnRight().DeScratch().TurnLeft().MV2()
Interleave(a,b,c)
LimitedSharpenFaster()
AddGrainC(1.5, 1.5)
AssumeFieldBased()
Weave()
return last
### --- Save with Lagarith as YV12 --- ###

#..........................................................................................
### --- REMOVE DIRT & REMOVE DIRT MC FUNCTIONS --- ###
### --- -------------------------------------- --- ###
### --- Required: RgTools.dll & RemoveDirt.dll --- ###

function RemoveDirt(clip input, int "limit", bool "_grey")
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=30,cthreshold=8,\
     gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)

  # Alternative settings
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6,\
  #  gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8,\
  #  gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,\
  #  grey=_grey,show=false)
}

function RemoveDirtMC(clip, int "limit", bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

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

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=20)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=20)

  backw = MFlow(clip,super,bvec_re,thSCD1=900,thSCD2=200)
  forw  = MFlow(clip,super,fvec_re,thSCD1=900,thSCD2=200)

  clp=interleave(forw,clip,backw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}


#..........................................................................................
function MV2(clip)
{
### --- copy of modified MDeGrain2 MVTools filter, renamed "MV2" ---- ###
### --------- (requires MVTools2.dll and aWarpSharp.dll)  ----------- ###
source=clip

  super = source.MSuper(pel=2, sharp=1)
  backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=8, overlap=4, dct=0)
  backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=8, overlap=4, dct=0)
  forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=8, overlap=4, dct=0)
  forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=8, overlap=4, dct=0)
  MDegrain2(source,super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)

    clean=last #save cleaned version
    diff1=subtract(source,clean).Blur(0.25)
    diff2=diff1.blur(1.5,0)
#diff3 is high-ish frequency noise only
    diff3=subtract(diff1,diff2)
#sharpen cleaned version a little
    sharpen(0.3,0.0)
#mix high frequency noise back in
    overlay(last,diff3.levels(128,1.0,255,0,127,coring=false),mode="add", opacity=0.7)
    overlay(last,diff3.levels(0,1.0,127,128,255,coring=false).Invert(),mode="subtract", opacity=0.7)
#put cleaned chroma back in with warp sharpening
    mergechroma(clean.aWarpSharp(depth=20.0, thresh=0.75, blurlevel=2, cm=1))

return last}
aud=ffaudioSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
vid=ffvideoSource("Drive:\path\to\Chinnvar Movie Comedy.mp4")
AudioDub(vid,aud)

This code uses functions of the FFMS2 plugin to open and decode an mp4 sample. The statements were described in detail in the early part of post #28 (http://www.digitalfaq.com/forum/vide...html#post53891).

## --- The line below is a comment. Remove the # character to execute the code. --- ##
## --- If working with the YUY2 original, the code converts to YV12 color. -------- ##
# ConvertToYV12(interlaced=true)
All three of the above statements are comments. The first two statements describe how to enable or disable the third line. An explanation of how to use comment marks (#) to enable or disable a statement was explained in post #28 (http://www.digitalfaq.com/forum/vide...html#post53891). The remarks above explain that the code following these lines requires video that uses a YV12 olorspace. If the video isn't YV12, then remove the # mark from "# ConvertToYV12(interlaced=true)" so that it will execute. If you don't want that statement to execute, let the statement remain as a comment by not changing it.

AssumeTFF()
This line was accidentally left in the scripts because it was part of a group of previously used routines that were pasted into the posted text. People often save the text of entire posted routines, or they create routines and then save the text, so that the same routines don't have to be typed again and again. In this case "AssumeTFF()" wasn't needed because the video is not interlaced and, therefore, field order doesn't matter. This was explained earlier in post #14 (http://www.digitalfaq.com/forum/vide...html#post53794).

SeparateFields()
Source=last

a=source1.SelectEvery(3,0).RemoveDirtMC(50,false). Descratch().TurnRight().DeScratch().TurnLeft().MV2 ()
b=source1.SelectEvery(3,1).RemoveDirtMC(50,false). Descratch().TurnRight().DeScratch().TurnLeft().MV2 ()
c=source1.SelectEvery(3,2).RemoveDirtMC(50,false). Descratch().TurnRight().DeScratch().TurnLeft().MV2 ()
Interleave(a,b,c)

This is the same routine that is used in the new script, but it uses different filters. There are a few differences between the routine used above in the first script and the similar routine in the newer script: (a) SeparateFields() (http://avisynth.nl/index.php/SeparateFields) was not used in the new script and was not needed, and (b) the new script didn't use the DeScratch plugin, and (c) TurnRight() and TurnLeft() were not used. The logic behind this code was explained in the early paragraphs of post #32 (http://www.digitalfaq.com/forum/vide...html#post53950).
The routine calls for the use of a filter named "MV2(()". The text of that filter appears in its entirety in the lower third of the old script, rather than being imported with the Import() function. In the new script MV2 was imported as the DGM2.avs plugin. "MV2" and "DGM2" are the same filter using different names.

The routine calls three Avisynth filters by name: RemoveDirtMC, Descratch, and MGV2. Descratch is an Avisynth .dll in the plugins folder, and its code will load automatically when this routine is executed. However, RemoveDirtMC and MV2 are filters in the form of text code, which will not load automatically. The text of the code for those two filters is pasted directly into the middle and bottom of the old script beginning with the line "### --- REMOVE DIRT & REMOVE DIRT MC FUNCTIONS --- ###" and the line "function MV2(clip)".

LimitedSharpenFaster()
AddGrainC(1.5, 1.5)

The use of these two plugins was explained in the new script in post #32 (http://www.digitalfaq.com/forum/vide...html#post53950).

AssumeFieldBased()
Weave()

Remember that SeparateFields() was used earlier in the script (it was not used in the new script), so that by the time the executing code arrives at the "AssumeFieldBased()" line, the video consists of half-height frames instead of full-sized frames. As half-height frames, the frames are 720x288 rather than 720x576 -- each half-height frame contains only 288 alternating lines of the original progressed frames. What has to be done at this point is to rejoin (Weave) the 288 scanlines from every two half-height frames to make them full=sized frames again. To prevent you from trying to join full frames in error, the Weave() function checks to see if you're working with field-based video rather than full-frame-based video. Because of the use of DeScratch and the nature of its output, Avisynth doesn't know whether the video is field-based or not (this sometimes happens with a few other Avisynth filters, such as Daa and SangNom). So AssumeFieldBased() is used to let Avisynth know what to do. After these two lines are executed, the video's frames are reassembled into their original form.
AssumeFieldBased: http://avisynth.nl/index.php/Parity
Weave: http://avisynth.nl/index.php/Weave

return last
Execution of the main body of the script ends here, and Avisynth returns the results of the processing that precedes this statement. The code that appears below this line is the text of two filters (i.e, RemoveDirtMC and MV2) that were calleld from the main body of the script.

function RemoveDirt(clip, int "limit", bool "_grey")
This line is the start of the text of two sub-functions, or filters, named RemoveDirt and RemoveDirtMC. These two functions are the contents of the filter named RemoveDirtMC.avs, which can be downloaded from http://www.digitalfaq.com/forum/atta...emovedirtmcavs. In this case the complete text of the filter has been pasted into the script rather than imported with the Import() function.

This is a denoising filter designed by a software designer who knows how to create video filters, so I could only guess at all the details involved. The filter consists of two major subfunctions. The code of the first major sub-function begins with the line "function RemoveDirt(clip, int "limit", bool "_grey"). The named function's code begins with the "{" bracket and ends with a closing "}" bracket 13 lines later. The code for the second sub-function begins with "function RemoveDirtMC(clip, int "limit", bool "_grey")" -- its processing also begins with an open "{" and ends with a closing "}".

Both of these RemoveDirt functions accept the same three parameters, which are named "clip", "limit", and "_gray". This means that when you call for either of these functions, you have to send them three values in parentheses. The value for the "clip" parameter isn't necessary because it's known as an "understood default". The default value for clip is "last", i.e., the video that resulted from the last statement performed before calling this filter.

The second parameter that is passed is "limit". It looks like another understood default but, actually, if you don't explicitly state a value for "limit" you'll get an error message. In the code it looks as if the default value is 6, but that will generate an error. Old instructions for this filter state that any value between 10 and 100 can be used for the limit parameter. That's true, but any value over 50 will result in some small objects disappearing during motion and/or an over-softening of the video. Users know from experience that values between 10 and 40 seem to be the most popular. In this case 50 was found to be effective on some bigger spots and scratches, but higher values weren't worth the trouble.

The third parameter used by this filter is "_gray", which must be either true or false. It should be specified as false unless you're dealing with pure monochrome video, when it should be set as true. How do we arrive at these values? By reading the instructions that came with the original RemoveDirt.dll (http://www.digitalfaq.com/forum/atta...ovedirt_v09zip) and by consulting RemovDirt's wiki page (http://avisynth.nl/index.php/RemoveDirt). And also from seeing how other users applied the filter in many other restoration threads.

The filter is being called from the main program code as "RemoveDirtMC(50,false)". It can also be called as "RemoveDirtMC(last,50,false). But because "last" is an understood default, both statements are equal. Almost every filter or function in AVisynth uses "last" as its understood default for input.

The filter is OK for simmering tape noise, most forms of grain, and some forms of spots. Using very high strength valus for "limit" can overly smooth many fine details. The main processing lines are the code in the RemoveDirtMC section that mention MSuper, MAnalyze, M<Recalculate and Mflow. These are clues telling you that functions from the MVTools plugin are being used (https://avisynth.org.ru/mvtools/mvtools2.html#functions). These functions track the behavior of pixels across multiple frames, and then decide if the difference between pixels that change is because they're noise or they're in motion.

function MV2(clip)
This filter in the lower 1/3 of the script is code that has been pasted into the script rather than imported with the Import() function. The MV2 code has an understood default value of "last" for the "clip" parameter. Because "last" is the understood default and is the only parameter, the filter can be called simply as "MV2(). I later renamed MV2 and called it MDG2.avs, which can be downloaded from http://www.digitalfaq.com/forum/atta...1&d=1524917341.

As mentioned earlier, the processing in MV2 (aka MDG2) is mostly a copy of the MDegrain2 routine that appears in the documentation for MVTools2.dll (https://avisynth.org.ru/mvtools/mvtools2.html#functions). After looking backward a few frames, and then forward a few frames, the filter does some creative masking, blurring and Overlays to destroy noise while at the same time retaining as much detail as possible.
Overlay: http://avisynth.nl/index.php/Overlay

The script ends with the last line of the MV2 function code.

I don't usually paste the text of .avs filters into the same code with Avisynth scripts. I just get lazy and use the Import() function. The only pasting I usually do is quick and short text that I would otherwise have to retype thousands of times, such as the path to my Avisynth plugins folder.

Should you decide to paste quickie text lines or routines, you might want to try building a text file of short lines that you find yourself typing over and over. You wouldn't want to paste the text of really long .avs or .avsi filters. For example, the .avsi text file for RemoveSpotsMC4. which contains RemoveSpotsMC3, is 557 lines.
Reply With Quote
The following users thank sanlyn for this useful post: wimvs (05-05-2018), yukukuhi (05-05-2018)
  #50  
05-05-2018, 03:12 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Thanks yet again for breaking it down.

And could you tell me for which kinds of noises can RemoveDirtMC used for?

I could figure MV2 (aka MDG2) is used for removing grains.

Also what's with the 4 versions of RemoveSpotsMC! What's the difference?
Reply With Quote
  #51  
05-05-2018, 04:11 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
The first question has been answered by you in your recent post before mine.
Reply With Quote
  #52  
05-05-2018, 06:49 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by yukukuhi View Post
Thanks yet again for breaking it down.

And could you tell me for which kinds of noises can RemoveDirtMC used for?

I could figure MV2 (aka MDG2) is used for removing grains.

Also what's with the 4 versions of RemoveSpotsMC! What's the difference?
MDG2 is really MDegrain2 with some added cleanup code to help avoid an over-filtered look. There is also an MDegrain and an MDegrain3. The main difference is in how many frames are analyzed in a forward and backward direction. As more frames are analyzed, processing time increases. Also, as more frames are analyzed, the more likely "real" detail will be removed along with more grainy noise. MDegrain2 is a compromise between the other two versions. They tend to remove large clumps of lighter-colored grain and some angular grayish scratches and smudges. MDegrain is also somewhat useful in smoothing noisy edges. It appearas to be more subtle than many other denoisers.

RemoveDirtMC and RemosSpotsMC are very similar filters. RemoveDirt is known to remove blotchy chroma patches, many kinds of horizontal dropouts (ripples or static), and many types of spots -- but for some reason, the brighter the spot the more RemoveDirt ignores it). It also works on darker types of angular scratches than MDegrain does.

The different versions of RemoveSpots and RemoveSpotsMC differ by iteration. All of the RemoveSpots versions use special modes of RemoveGrain that look at smaller and bigger grain. The cleaners look at and compare more frames forward and backward and apply the base cleaners more times to more frames. A "spot" can also be something that isn't simple and round like a raindrop,it can be angular, or it can be a small blob with a long tail (called a comet), or can even be a line that culminates in a thicker end (more like a scratch or horizontal dropout). The basic RemoveSpotsMC is a fast running filter. RemoveSpotsMC2 runs everything twice and is slower. As you can imagine, RemoveSpotsMC3 runs everything three times and is very slow, while RemoveSpotsMC4 slows to a crawl and, for all practical purposes, is not that much of an improvement over RemoveSpotsMC3.

All three filters -- MDegrain, RemoveDirt, RemoveSpots -- require some experimentation because they're all based on similar methods. There are other denoisers around that are very popular when spots and scratches aren't so dominant, such as the denoisers and shimmer smoothers in QTGMC and MCTemporalDenoise, (The latter two filters get support from RemoveGrain, dfttest, and fft3d), and the removal of thick and heavy grain by TemporalDegrain. Each works on different types of noise in different ways, each also destroys detail in different ways and finds ways to minimize the destructive side and/or to protect or restore detail that is affected.

Here are links to video with different noise problems -- VHS tape noise, object shimmer, flicker, noisy edges, chroma noise and blotches, chroma bleed, etc. The source is a bad cable signal in 1991, aging VHS tape, a cheap RCA VCR, and recording at slow 6-hour speed on cheap NTSC tape. For capture the tape was played with a Panasonic PV-S4670 VCR with a Panasonic ES10 for pass-thru line tbc, an AVT-8710 frame tbc, into an ATI 7500 AIW AGP capture card, with VirtualDub capture to huffyuv lossless AVI. Flicker and tape noise are obvious in the background of the opening shot. Shimmer is obvious in the second shot locomotive as it approaches the camera. A large gray spot in the center of the frame flashes near the end of the third shot. Each clip is ~33 MB.

The original Liv5A_cut_EP_original_cap.mp4 is an unfiltered h.264 encode of the original capture. It is telecined with 3:2 pulldown.

The cleanup is Liv5A_ivtc_cut_EP_playback sample.mp4. The main filters used were TIVTC (for telecine deinterlace and removal), QTGMC in progressive-video mode with dfttest denoising, plus plain-vanilla RemoveSpots, and unmodified MDegrain2. Color tweaking was with VirtualDub.

The samples were originally posted to show that with a bad signal and EP recording one can still get a decent video with good hardware and patient post-processing. It also demonstrates that different media has different problems and requires different filters.
Reply With Quote
The following users thank sanlyn for this useful post: wimvs (05-05-2018), yukukuhi (05-05-2018)
  #53  
05-05-2018, 10:32 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Yeah i understand the difference now.

Quote:
Originally Posted by sanlyn
Yes, I know. Very tricky at first. There's another way: buy a really pricey NLE that creates overlays, frame by frame, one at a time, and then create a new video from the repaired frames.
As you've menioned this earlier in post #33 for the ReplaceFramesMC filter, is there really a NLE that does the job equal to the Avisynth filter?

And also as a replacement for the Vdub colour correction filters, will Adobe Premier Pro suffice?

P.S. I want your honest opinion of wether or not would NLE match up to Avisynth filters in terms of performance as well as the side effects.
Reply With Quote
  #54  
05-05-2018, 11:37 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by yukukuhi View Post
Yeah i understand the difference now.



As you've menioned this earlier in post #33 for the ReplaceFramesMC filter, is there really a NLE that does the job equal to the Avisynth filter?

And also as a replacement for the Vdub colour correction filters, will Adobe Premier Pro suffice?

P.S. I want your honest opinion of wether or not would NLE match up to Avisynth filters in terms of performance as well as the side effects.
You can use Premiere Pro for color correction. You can't use the same settings that are used with Virtualdub's controls, which means you find suitable corrections in Premiere from scratch. Many corrections are best done in YUV before going to RGB color. Adobe does allow color and levels work in YUV. You should be aware that Adobe doesn't convert colorspaces as cleanly as Avisynth.

No one would recommend Premiere or any other NLE as a repair and restoration platform that can compete with Avisynth for that purpose. That's not what NLE's were designed for. By the same token, Avisynth can't compete with an NLE's timeline editing and special effect features.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-05-2018)
  #55  
05-05-2018, 11:49 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Cool.

So far YUV i'll use Avisynth, convert to RGB using Avisynth & then load on to Premier Pro. Is that right?
Reply With Quote
  #56  
05-05-2018, 12:51 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
That would be the best way. I make that RGB conversion the same way with VirtualDub, too, especially with interlaced video. The Avisynth "secret stuff" for colorspace conversions wants you specify whether interlaced or not. If telecine is involved, consider it interlaced unless telecine has been removed. The Avisynth conversion algorithms for interlaced and non-interlaced video are performed differently because of the way chroma information is stored in different colorspace and frame structures. Most NLE's don't make those distinctions, so you end up with less precision and accuracy.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-05-2018)
  #57  
05-05-2018, 11:56 PM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
Does Premier Pro handle well with interlaced videos?

Is it best to deinterlace master source of HD PVR Recordings of Digital tv broadcasts?

Also is it best to avoid DeScratch filter that which introduces artifacts?
Reply With Quote
  #58  
05-06-2018, 05:01 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by yukukuhi View Post
Does Premier Pro handle well with interlaced videos?
Premiere Pro is only average at dinterlacing. It's no better in this respect than any other editor at any price. VirtualDuib can deinterlace as well using its built-in yadif filter, which is often better than some cheaper editors. One problem with Premier Pro and deinterlacing is that PP doesn't use motion compensated techniques, and uses inferior resizing methods when interpolating half-height frames into full frames.

The best deinterlacer available today is QTGMC in AVisynth. It works as well as any good TV or media player, and better than some.


Quote:
Originally Posted by yukukuhi View Post
Is it best to deinterlace master source of HD PVR Recordings of Digital tv broadcasts?
Software deinterlacing always has a cost no matter how it is done, even with a champ like QTGMC. Note that not all broadcasts are pure interlace video; With PAL, many are like your samples, which are progressive video encoded as interlaced. If you deinterlace such a video you will simply get duplicate frames. Some videos are adapted from NTSC which usually requires field-blended techniques of one kind or another, and many simply cannot be deinterlaced. Some are film sources that use periodic field or frame duplication, or some form of pulldown; these require special deblending and inverse telecine techniques in Avisynth. Premiere Pro has no way to repair such videos, even though PP and similar NLE's are often used to create the unwanted structures. Many adaptations cannot be restored to their original form.

Smart TV, PC media players, and external media players can play interlaced and telecined videos. You watch interlaced and telecined video all the time through your cable box and with retail DVD's and BluRay (many BluRay formats are interlaced or telecined). Repairing bad video and processing for the internet are the best reasons for deinterlacing -- unless you just want to do it, of course.

Quote:
Originally Posted by yukukuhi View Post
Also is it best to avoid DeScratch filter that which introduces artifacts?
No one has made a perfect filter for cleaning scratches. Your samples represent a worst-case scenario. Most video is not that badly damaged. Something with a bad scratch or two at infrequent intervals could benefit from descratch, but remember that it has its limitations as all filters do. I would try RemoveDirt or RemoveSpots first, and there are other filters that work with median techniques that can be helpful -- but median filters, too, have their limits and are designed primarily for cleaning dropouts. These filters, like Descratch, can often cause unwanted distortion. It depends on the video being processed.

Rather than film-style scratches, a more common problem would be mild or severe dropouts and ripples from damaged tapes -- although now and then you see somewhat similar defects being broadcast in one form or another.

Here is an example frame from a forum thread about very severe dropout problems:



In the original sample, the dropouts were followed by a few frames where the recovering tape player didn't restore the color, and across the center you see remnants of a smaller dropout that looks like a thin horizontal white scratch:



Here is the short, damaged original mp4 video sample: "raw.mp4" (interlaced PAL, 7MB)

Here is the repair with an Avisynth median filter, chroma borrowed from a following frame, and corrected levels:
"raw_fix_PAL_mp4" (interlaced PAL, 8MB)

To recover chroma-only is possible with built-in Avisynth functions. You could not repair the uncolored frame by simply replacing the black and white frame with another frame because the camera and the baby were in motion during this sequence. Unfortunately, when I tried median filters used on your badly scratched Chinnvar samples they were even worse than Descratch and caused many bizarre distortions. There simply were not enough intermediate "good" frames for motion-averaging median filters to work with.


Often the problems are less complicated. Example: the frame below is from a telecined broadcast movie that had signs of film damage. Notice the bright, two-headed white "demon spot" below the dancer's feet:



This was fixed by borrowing a motion interpolated patch of floor detail from a previous and following frame. You could do something similar in Premiere Pro, although you'd have to do some mild blurring to make the patch fit neatly into the bad area:





None of this is to say that Premiere pro isn't an excellent editor with many good features that most users never bother to use (which is a silly way to simply waste your money). But it is an editor, not a restoration platform. It generally works well at what it was designed to do, and comes with a very good encoder and excellent advanced color correction controls, similar to those in my copy of AfterEffects.

Last edited by sanlyn; 05-06-2018 at 05:27 AM.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-06-2018)
  #59  
05-06-2018, 09:33 AM
yukukuhi yukukuhi is offline
Free Member
 
Join Date: Apr 2018
Posts: 68
Thanked 0 Times in 0 Posts
I pretty well understand that Premier Pro cannot deinterlace properly, but I wasn't asking about that. What i meant was wether it can import interlaced footage, make required colour correction & finally export output video as interlaced also without suffering loss in quality.
Reply With Quote
  #60  
05-06-2018, 09:45 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by yukukuhi View Post
I pretty well understand that Premier Pro cannot deinterlace properly, but I wasn't asking about that. What i meant was wether it can import interlaced footage, make required colour correction & finally export output video as interlaced also without suffering loss in quality.
Premiere can do that. Use the Lagarith compressor for your lossless working files. Premiere gets clumsy with huffyuv sometimes, which doesn't work with YV12 anyway. Convert to RGB32 in Avisynth for import into PP.
Reply With Quote
The following users thank sanlyn for this useful post: yukukuhi (05-06-2018)
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Horizontal lines/scanlines in captures? (ATI 600 USB) Turok81 Capture, Record, Transfer 8 11-27-2016 08:25 PM
My guide on removing vertical jitter using VirtualDub and Photoshop hysteriah Restore, Filter, Improve Quality 6 06-08-2015 04:45 AM
Need help with blue vertical lines max_cady Restore, Filter, Improve Quality 3 05-03-2011 04:24 AM
Vertical or horizontal for storing an external hard drive & best enclosures ? Sossity Computers 1 12-09-2010 07:26 PM




 
All times are GMT -5. The time now is 12:00 AM