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. |
|
![]() |
#1 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
MDec2 - v1.02 - 26 Apr 2018
dll's for Avisynth v2.58, Avs+v2.6 x86 and x64.
Requires CPP runtimes for VS 2008. Code:
MDec2 by StainlessS MDec2, MultiDecimate like decimating filter. Planar, YUY2, RGB MDEC2(clip c,float "rate"=24.0,bool "show"=false,bool "create"=false,string "dir"="C:\",bool "chroma"=true,bool "ver"=false) MDec2 is a 2 pass decimating filter, acting much like the Multidecimate filter by Donald A. Graft. Requires MultiDecimate.Exe & ProcessMD.Exe from MultiDecimate package. Args:- c, clip. No default Rate=24.0, final output frame rate, used only on 2nd pass. show=false. 1st pass, shows metrics on frame, 2nd pass shows frame being used. create=false. Set true for 1st pass, false on 2nd pass after using MultiDecimate.Exe. dir="C:\". Path to data files (mfile.txt, cfile.txt, dfile.txt). chroma=true. If false then only use luma for metrics. (RGB not used). ver=false. True shows version on frame. See MultiDecimate docs for further info. Metrics:- MDec2, modified metrics based on FDecimate by Donald Graft. Splits frames into blocks and returns metric of block with greatest difference. YUV Metrics weight combined chroma with same weight as luma. NOTE, if wanting to eg decimate 29.97 to 25.0, then numbers dont work and will throw an error because of mismatch to what it is expecting. In such circomstance, use something like:- >>>>>>>>>>> SHOW=True ORG=Last AssumeFPS(30.0,sync_audio=True) # ResampleAudio(ORG.AudioRate) Mdec2(Rate=25.0,create=True,Show=True,Dir="") # Pass 1 [Dir="", files in current directory] ### Use MultiDecimate.Exe, eg drop 1 frame in every 6. ###### SHOW=False ORG=Last AssumeFPS(30.0,sync_audio=True) ResampleAudio(ORG.AudioRate) Mdec2(Rate=25.0,create=False,Show=SHOW,Dir="") # Pass 2, output 25 fps. <<<<<<<<<<< StainlessS Code:
######################################################################## # Script to test metrics of MultiDecimate, FDecimate and MDec2. # # MultiDecimate v1.07 & FDecimate v1.02/v1.10 metrics are both bugged. # ######################################################################## #Loadplugin("MDec2_x86.dll") Loadplugin("Multidecimate.dll") #Loadplugin("FDecimate.dll") MODE=1 # Testing Mode, 0 = MDec2 : 1=MultiDecimate : 2=FDecimate (All three should show metrics as 100.0%) # 0) MDec2, any valid 8 bit ColorSpace. Metrics shown on frame. (only 100.0% @ PC Levels) # 1) MultiDecimate YUY2 ONLY, Metrics stored script directory MFile.txt. (YUY2, Shows 108.51% Qual=2, 217.02% Qual=3) # 2) FDecimate YV12 and YUY2, Metrics shown on frame. (Shows 187.68% for YV12, 112.61% YUY2) C="YUY2" # Choose Test Colorspace (must be valid for the called dll) MDQUAL=2 # MultiDecimate Quality setting default 2. 2=Luma Only : 3=Luma+Chroma IsRGBClip=FindStr(C,"RGB")!=0 W=(IsRGBClip) ? BlankClip(Pixel_Type=C,Color=$FFFFFF) : BlankClip(Pixel_Type=C,Color_YUV=$FFFFFF) K=(IsRGBClip) ? BlankClip(Pixel_Type=C,Color=$000000) : BlankClip(Pixel_Type=C,Color_YUV=$000000) Interleave(W,K) # White/Black(RGB) or Pink/Green(YUV) alternate frames MODE==0 ? MDec2(rate=25.0,create=true,Show=true,dir="",Ver=True,Chroma=true) : \ MODE==1 ? MultiDecimate(Pass=1,Show=True,quality=MDQUAL) : \ FDecimate(Rate=25.0,Metrics=true) Return Last Zip contains dll's + source + FDecimate() original source. (metrics modified from FDecimate metrics). Zip ~ 120KB. See MediaFire or SendSpace below this post in my sig. EDIT: Original MultiDecimate page gone, so also available here:- http://www.mediafire.com/file/bw4i71...ecimate107.zip (maybe of use for docs, and MultiDecimate.exe and ProcessMD.exe).
__________________
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; 27th April 2018 at 01:05. Reason: Update |
![]() |
![]() |
![]() |
#2 | Link |
Huba Huba
Join Date: Aug 2005
Location: Palumbian Jungle
Posts: 78
|
MediaFire link seems to be dead (404) - can you please re-upload? Thanks!
__________________
"The innocent have nothing to fear" :stupid: |
![]() |
![]() |
![]() |
#3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
404 is a MediaFire problem, I have reported it. this should work: LINK REMOVED
EDIT: Link in sig now working OK.
__________________
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; 29th November 2013 at 15:36. |
![]() |
![]() |
![]() |
#4 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Can this be used to keep the 2nd copy of a set of repeating frames? There's a few cases for this. For one thing, imagine 24fps film encoded to 720p60. There's up to 3 repeated frames, but because of the encoding, the first in the sequence is low quality, and it's better to get the frame after, where the P frame is correcting the last I frame.
Another case is pulldown. I'd like to average the two repeating fields for better quality. Another use is dot crawl; if you average the same image on two frames it perfectly removes dot crawl, as if it were s-video. There was one other use I can't remember. |
![]() |
![]() |
![]() |
#5 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Sorry no. It is MultiDecimate.Exe that selects which frames to keep, MDEC2 only provides the metrics.
Source for MutiDecimate.Exe/Process.Exe was (I think) never published. EDIT: Source for the dll was never published either.
__________________
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; 11th December 2013 at 18:29. |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,656
|
I am not sure I understand what problem this is solving. I use TFM all the time to create metrics in pass 1 which I then pass through Multidecimate.exe. In pass 2 I use "MultiDecimate(pass=2)" to read the metric files created by Multidecimate.exe (mfile.txt, etc.) and actually decimate the file by some arbitrary amount (i.e., non repeating patterns).
So what part of this workflow is MDec2 designed to replace, and what advantages does it have over existing solutions? |
![]() |
![]() |
![]() |
#7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Hi john, I wrote it for myself for the YUY2 and YV12 and RGB capability, someone in some thread asked where to get source for Multidecimate,
so I (cleaned up and extended) posted what I had done. Multidecimate even in pass 2 does not support YV12 (EDIT: Or was it YUY2), even though all that is needed is return the next non decimated frame without actually needing any knowledge of the colorspace (unless metrics required). EDIT: You could continue to use TFM and Multidecimate.exe and just use MDEC2 for the second pass if you like (if YV12 or RGB). I've no idea offhand what colorspaces TFM supports to provide metrics. EDIT: Forgot, v2.6 planar compatible.
__________________
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; 30th March 2015 at 21:48. |
![]() |
![]() |
![]() |
#9 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Posting prompted this: http://forum.doom9.org/showthread.ph...16#post1577816
A bit more here: http://forum.doom9.org/showthread.ph...69#post1644669
__________________
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; 12th December 2013 at 01:50. |
![]() |
![]() |
![]() |
#10 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
MDec2 v1.01, 30 Mar 2015. Recompile v2.6 dll with Avisynth Version 6 Header.
See 1st post.
__________________
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 ??? |
![]() |
![]() |
![]() |
#11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
MDec2() v1.02, 26 Apr 2018, new version.
Dll's for avs v2.58, avs+ v2.60 x86 and x64, see first post. EDIT: Code:
Modified by StainlessS, metrics from FDecimate by Donald A. Graft (Neuron2). v1.00, 9 Aug 2013. Early release. v1.01, 30 Mar 2015. Recompile v2.6 dll with Avisynth Version 6 Header. v1.02, 26 Apr 2018. Fix pitch can change. Add x64 dll. Recompile VS2008. FDecimate metrics bug adds chroma difference to the wrong luma difference block. Here FDEcimate on YV12 (v1.02, v1.10 same bug). ![]() MultiDecimate is also bugged but dont seem as bad. (no source to check)
__________________
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; 27th April 2018 at 13:20. |
![]() |
![]() |
![]() |
#12 | Link |
Registered User
Join Date: Oct 2018
Posts: 131
|
First, thanks for the work! But I can't figure out how to run it
![]() I do: tfm() MDec2(create=true, dir="D:\myfolder") Then I run the avs through megui and only the encoded video file comes out.... no txt files. Perhaps this serves as a nudge to write an example or two here http://avisynth.nl/index.php/MDec2 ![]() |
![]() |
![]() |
![]() |
#13 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Dont use MeGUI on first pass (it does all kinds of weird multiple scan stuff).
You need scan complete clip in eg VDub2 [EDIT: Run Video Analysis Pass], on closure should produce result mfile.txt text file (same as Multidecimate). Use the Multidecimate.Exe file to produce cfile.txt and dfile.txt files. Run 2nd pass with create=false (and rate arg set, can use 2nd pass in MeGUI). It is assumed that you have used multidecimate before [and have the MultiDecimate.Exe and ProcessMD.exe from Multidecimate]. EDIT: It also puts out error message to DebugView if cannot write file for some reason, see Debugview (Google). EDIT: Multidecimate:- https://avisynth.org.ru/docs/english...tidecimate.htm EDIT: DebugView:- https://docs.microsoft.com/en-us/sys...oads/debugview
__________________
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; 7th June 2020 at 18:40. |
![]() |
![]() |
![]() |
#14 | Link |
Registered User
Join Date: Oct 2018
Posts: 131
|
Thanks, that was useful. I've the three text files now (they look legit, with many lines of data), but when I try to preview the second pass I get (in avspmod):
MDEC2: incompatible number of frames. script: Code:
MPEGSource("file.d2v",cpu=0) tfm() MDec2(create=false, rate=20,dir="mypath") FWIW I want to get rid of dupes in this file which are distributed haphazardly, in some sections I think a TDecimate(0,7,12) would do, but in others it has another repetition pattern which I suspect to be TDecimte(0,33,199) but I'm only 95% sure. Last edited by bruno321; 7th June 2020 at 19:33. |
![]() |
![]() |
![]() |
#15 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
And what was the rest of the output to debugview ?
Code:
sprintf(buf,"MDEC2: mode=%d cycle=%d drop=%d num_iframes=%d num_oframes=%d\n",mode,cycle,drop,num_iframes,num_oframes); OutputDebugString(buf); sprintf(buf,"MDEC2: num_frames_hi=%d num_frames_lo=%d\n",num_frames_hi,num_frames_lo); OutputDebugString(buf); sprintf(buf,"MDEC2: Incompatible Number of frames\n"); Insert "Return Info" before Mdec2 EDIT: Oh, and by the way, I've only ever used with the Naive Multidecimate.exe option, no idea if works with the option you chose. [its actually multidecimate.exe that makes decision what to drop] EDIT: It will throw a wobbly, if framecount after decimation is not exactly as expected for output rate.
__________________
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; 8th June 2020 at 00:16. |
![]() |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Oct 2018
Posts: 131
|
Framecount before or after tfm (no difference): 13960
Here's the output of debugview. First with the "Protect static scenes" option, then without: Code:
[10324] MDEC2: Opening file D:\dfile-protect.txt [10324] MDEC2: mode=1 cycle=5 drop=1 num_iframes=13960 num_oframes=7167 [10324] MDEC2: num_frames_hi=13960 num_frames_lo=6986 [10324] MDEC2: Incompatible Number of frames [10324] MDEC2: Opening file D:\dfile.txt [10324] MDEC2: mode=0 cycle=5 drop=1 num_iframes=13960 num_oframes=6025 [10324] MDEC2: num_frames_hi=13960 num_frames_lo=6986 [10324] MDEC2: Incompatible Number of frames |
![]() |
![]() |
![]() |
#17 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Quote:
Sorry, I meant that I've only ever used it with "Cycle based Naive" (3rd one in list) not "Global Naive" [with threshold]. If say input framecount is 3000 @ 30.0 FPS, and remove 1 from cycle of 6 frames, so, output framecount = 3000 * ((6-1) / 6) = 2500 : in_frame_count * ((cycle-1)/cycle) output framerate = 30.0 * ((6-1) / 6) = 25.0 FPS The check is basically so it can ensure that no cockup has been made, and is probably not necessary, but I prefer as is, as it has told me of my error more than once. I dont like the other modes of Multidecimate, I only ever used the one mentioned for N in Cycle decimation, I actually wrote it (Mdec2) for myself as Multidecimate supported only YUY2. Somebody asked about YV12 support for Multidecimate, so I posted my personal use tool, MDec2. If you need arbitrary decimation where output rate or framecount is not predictable and audio sync is not required, then I guess you are stuck with Multidecimate's other modes or some other dedupper, sorry. Suggestions in addition to TDecimate, ExactDeDup(), where dupes are bit exact duplicates, single bit different is not a dupe, this should be very fast where many identical dupes. Duplicity2(), good where difficult to detect duplicates (where will interpolate dupes, or create a dupes file of dupe frame numbers). EDIT: Maybe I try find time to see if I can skip the check, "Incompatible number of Frames" (or whatever is was).
__________________
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; 8th June 2020 at 15:34. |
|
![]() |
![]() |
![]() |
#18 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Bruno,
You wanna give this a go [MDEC2 v1.03Beta1] :- http://www.mediafire.com/file/cb6i7m...00609.zip/file Should now work with all four decimate modes of Multidecimate. Rate arg now does nothing. Dir arg default no longer 'C:\', dont work on Vista+, also '.\' current directory broken on vista+, both fixed with new default of current script directory, ie '.\' Code:
Modified by StainlessS, metrics from FDecimate by Donald A. Graft (Neuron2). v1.00, 9 Aug 2013. Early release. v1.01, 30 Mar 2015. Recompile v2.6 dll with Avisynth Version 6 Header. v1.02, 26 Apr 2018. Fix pitch can change. Add x64 dll. Recompile VS2008. v1.03, 09 June 2020. Changed default directory Dir=".\", ie current directory, old default "C:\" not good under Vista+. Fix current directory relative. (Broken/changed under Vista/W7+). Ignore Rate arg, calc new rate using vi.MulDivFPS(output_frame_count,input_frame_count). Code:
MDec2 by StainlessS MDec2, MultiDecimate like decimating filter. Planar, YUY2, RGB, no change to audio. MDEC2(clip c,float "rate"=24.0,bool "show"=false,bool "create"=false,string "dir"="C:\",bool "chroma"=true,bool "ver"=false) MDec2 is a 2 pass decimating filter, acting much like the Multidecimate filter by Donald A. Graft. Requires MultiDecimate.Exe & ProcessMD.Exe from MultiDecimate package. Args:- c, clip. No default Rate=24.0, final output frame rate, used only on 2nd pass. ### v1.03, IGNORED, auto calculated from input framerate, input & output framecount. show=false. 1st pass, shows metrics on frame, 2nd pass shows frame being used. create=false. Set true for 1st pass, false on 2nd pass after using MultiDecimate.Exe. dir=".\". Path to data files (mfile.txt, cfile.txt, dfile.txt). ### v1.03, Now '.\' current directory, old 'C:\' broken by Vista+, cant write to 'C:\'. chroma=true. If false then only use luma for metrics. (RGB not used). ver=false. True shows version on frame. See MultiDecimate docs for further info. Give it a whirl please. EDIT: Also note, Could use with Avs+ additional PLANAR colorspaces in Pass 2 (I think, untested, so long as SHOW=FALSE, ie no metrics on frame), and use something like ConvertToYV12 for Pass 1. EDIT: PASS 1: (Create=true) Code:
AviSource("D:\Parade.avi") Assumefps(30.0,sync_audio=true) Mdec2(create=true,show=true) # Show onframe metrics not necessary Code:
00000077 0.16522254 MDEC2: Dir FullPath=D:\DUPES\mfile.txt 00000078 0.16527906 MDEC2: create=true, Pass 1, create multidecimate file 'D:\DUPES\mfile.txt' 00000079 0.16536927 MDEC2: Pass 1 Alloc arrays OK 00000080 23.46486092 MDEC2: File write OK # After full clip scan 00000081 23.46486092 'D:\DUPES\mfile.txt' PASS 2: (Create=false) Code:
AviSource("D:\Parade.avi") Assumefps(30.0,sync_audio=true) Mdec2(show=true) # Show onframe metrics not necessary Code:
00000238 0.16752903 MDEC2: Dir FullPath=D:\DUPES\dfile.txt 00000239 0.16759570 MDEC2: create=false, Pass 2, reading decimation file 'D:\DUPES\dfile.txt' 00000240 0.16772106 MDEC2: From File: mode=2 cycle=5 remove=1 num_iframes=7373 num_oframes=5898 00000241 0.16777469 MDEC2: From Clip: num_frames=7373 00000242 0.16940221 MDEC2: Output 5898 frames at 23.998 FPS # input was not an exact multiple of Cycle(5) frames (might ideally be 24.0 FPS). 00000243 0.16945148 MDEC2: Pass 2 Read decimation file OK Quote:
__________________
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; 9th June 2020 at 13:17. |
|
![]() |
![]() |
![]() |
#19 | Link |
Registered User
Join Date: Oct 2018
Posts: 131
|
Hey, thanks a lot for all this! Haven't yet looked at it in detail but the new version worked like a charm.
Input framerate: 25fps. Most of it had a 7-in-12 repetition pattern, so framerate would have been 12.488fps, but some short sections had a 33-in-199 patern, so with MDec2 I get a 12.935fps framerate which sounds sensible (in that it's slightly higher than 12.488) and looks good (some dupes remain but that's up to me to play with the threshold). I also had a similar problem with another file but where I couldn't discern any pattern. Input framerate: 25fps. MDec2 outputs a 20.864fps framerate which looks good. Weird framerates, I know, but these two sources are messed up. One question: I don't understand when should I use the "cycle based naive" option from Multidecimate. If I know the pattern, then why use Multidecimate when I can do m-in-n decimation with TDecimate? My motivation for using MDec2 was precisely these cases when I can't easily discern a global pattern of duplication. |
![]() |
![]() |
![]() |
#20 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,881
|
Main benefit of MDec2/Multidecimate (that I see), is that you can do Pass 1 scan once early on in complex restoration script (before adding any denoise/despot/descratch or whatever)
and later tinkering with script does not involve decimation scan every time you tweak a setting. Prior to MDec2 Pass 1, almost no filters before and DEFO NONE AFTERWARDS, I guess acceptable filters before are eg Tfm, AssumeFPS, and similar. Can add additional filters following MDec2 where Pass = 2 (Create=false). MDec2/Multidecimate Pass=2, is very light-weight, very little overhead in script. EDIT: I guess that the best reasons to use MDec2 may reside in Multidecimate docs (I have not looked at them recently), also examples are likely therein.
__________________
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; 9th June 2020 at 13:34. |
![]() |
![]() |
![]() |
Tags |
decimate, fdecimate, multidecimate |
Thread Tools | Search this Thread |
Display Modes | |
|
|