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. |
13th April 2014, 01:48 | #1 | Link | |||
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
Using avisynth for special interpolation
I want to interpolate frames of a video that looks like the following. It's 30 fps according to specs, but in reality has this order:
Quote:
Quote:
Could start with an offset. Goal is to create a good* transitionary image from 1 to 3 and 3 to 1 of the next round, so it looks like 30fps when it's in fact less that 15 fps. Like this Quote:
How do I do that in avisynth? * I love SVP. Maybe it's transition method can be used? Last edited by Kim Brandstetter; 14th April 2014 at 18:47. |
|||
13th April 2014, 02:56 | #3 | Link |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
Thanks. Doesn't that speed up or slow down the video? The Clones of previous movie pictures are there to keep the video in sync with the audio and in general to keep the video speed in sync with reality.
|
13th April 2014, 03:00 | #4 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
You either accept the duplicates or you remove them and do something with the decimated stream. You could try some motion adaptive frame interpolation, but it would have to start from the decimated stream. Your base stream is 11.988 fps. You can play it at that rate or you can make up some new frames.
Have you looked at the available motion-compensated interpolators. I don't know much about it but I have heard of mvflow, etc. Last edited by Guest; 13th April 2014 at 03:04. |
13th April 2014, 15:08 | #5 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
SelectEvery(5,0,2) automatically adjusts the video frame rate from 30 fps to 12 fps so there shouldn't be any audio desync.
Assuming the AABBB pattern is fixed throughout the whole video, you can use neuron2's suggestion as is, but if the pattern changes throughout the source, one way out is to use TDecimate(cycleR=3,cycle=5) or the slightly more accurate SelectEven().TDecimate(cycleR=1,cycle=5). These two alternatives also adjust the frame rate automatically. This is if you're okay with 12 fps output; if you want motion-interpolated 24/30/60/whatever fps output, you'll have to get rid of all the duplicates first (using any of the three methods mentioned above) prior to motion interpolation. |
13th April 2014, 17:04 | #6 | Link |
Big Bit Savings Now !
Join Date: Feb 2007
Location: close to the wall
Posts: 1,546
|
You may try filldrops123.avsi
Copy, paste, rename as filldrops123.avsi, put it into your plugins folder and call function as filldrops3. --------------------------------------- Code:
# johnmeyer's filldropsI (I for Interlaced) from 16.April 2011 based on MugFunky's filldrops see below, extended by Emulgator on 25.Feb.2012. # http://forum.doom9.org/showthread.php?p=1493082#post1493082 # Automatic dropping of duplicated frames/fields followed by generation of interpolated frames/fields and reinsertion. # Needs MVTools2, is more forgiving when duplicates do differ a little. # johnmeyers's Difference was 0.1, deviation now tunable. function filldropsI (clip c, float "dev") { dev=default(dev, 2.0) even = c.SeparateFields().SelectEven() super_even=MSuper(even,pel=2) vfe=manalyse(super_even,truemotion=true,isb=false,delta=1) vbe=manalyse(super_even,truemotion=true,isb=true,delta=1) filldrops_e = mflowinter(even,super_even,vbe,vfe,time=50) odd = c.SeparateFields().SelectOdd() super_odd=MSuper(odd,pel=2) vfo=manalyse(super_odd,truemotion=true,isb=false,delta=1) vbo=manalyse(super_odd,truemotion=true,isb=true,delta=1) filldrops_o = mflowinter(odd,super_odd,vbo,vfo,time=50) global devthresh=dev evenfixed = ConditionalFilter(even, filldrops_e, even, "YDifferenceFromPrevious()", "lessthan", "devthresh", show=true) oddfixed = ConditionalFilter(odd, filldrops_o, odd, "YDifferenceFromPrevious()", "lessthan", "devthresh", show=true) Interleave(evenfixed,oddfixed) Weave() } #[* # MugFunky's filldrops from 19.December 2005 # http://forum.doom9.org/showthread.php?p=753779#post753779 # "...so i wrote a little function to replace all frames that are identical to the previous one with a motion-interpolation of the adjacent frames. # it could be useful for captures that you can't get again, but are full of drops..." # Needs MVTools, duplicates must match perfectly, (useful only for capture drop&repeats). function filldrops (clip c, float "dev") { vf=c.mvanalyse(truemotion=true,pel=2,isb=false,delta=1,idx=1) vb=c.mvanalyse(truemotion=true,pel=2,isb=true,delta=1,idx=1) global filldrops_d = c.mvflowinter(vb,vf,time=50,idx=1) global filldrops_c = c global devthresh=dev c.scriptclip("""ydifferencefromprevious()<devthresh? filldrops_d : filldrops_c""") } #*] # MugFunky's filldrops from 19.December 2005, extended by Emulgator on 25.Feb.2012 # http://forum.doom9.org/showthread.php?p=753779#post753779 # "...so i wrote a little function to replace all frames that are identical to the previous one with a motion-interpolation of the adjacent frames. # it could be useful for captures that you can't get again, but are full of drops..." # Needs MVTools2, deviation now tunable. function filldrops2 (clip c, float "dev") { dev=default(dev, 2.0) super=MSuper(c,pel=2) vf=manalyse(super,truemotion=true,isb=false,delta=1) vb=manalyse(super,truemotion=true,isb=true,delta=1) global filldrops_d = mflowinter(c,super,vb,vf,time=50) global filldrops_c = c global devthresh=dev c.scriptclip("""ydifferencefromprevious()<devthresh? filldrops_d : filldrops_c""") } # filldrops3 based on MugFunky's filldrops from 19.December 2005, extended by Emulgator on 26.Feb.2012 to accommodate interpolation of Doupledrops # http://forum.doom9.org/showthread.php?p=753779#post753779 # "...so i wrote a little function to replace all frames that are identical to the previous one with a motion-interpolation of the adjacent frames. # it could be useful for captures that you can't get again, but are full of drops..." # Needs MVTools2, deviation now tunable. function filldrops3 (clip c, float "dev") { blksz=16 # Blocksize for Motion search. Default = 8. My Default 16: Delivers a smoother picture. 4: Gives too many artefacts with poorer source. searchp=32 # Radius for Motion search. Default = 2, My Default = 32 bld=true # Decides what to do if a Scenechange is detected by the following parameters: true will blend, false will repeat previous frame. SCDpb=800 # Default = 400. thSCD1. SAD (pixels*luma values) Threshold per Block. A Block exceeding this SAD is considered changed. ## SAD = Sum of Absolute Differences = Number of pixels per 8x8 block (=64) multiplied with their luma difference. ## SCDpb is always given related to 8x8 blocks and scaled internally to match other block sizes. SCDbp is thSCD1 and is evaluated before SCDpf=thSCD2 SCDpf=200 # 0-255, Default=130. thSCD2. Changed Blocks percentage threshold per frame. 0=0%, 127=50%, 255 = 100%. ## This Threshold sets which minimal percentage of changed blocks a frame has to contain to be considered as a scene change. dev=default(dev, 2.0) super=MSuper(c,pel=2) back_vec=MAnalyse(super, blksize=blksz, search=5, searchparam=searchp, isb=true, delta=1, temporal=false, dct=0, divide=0, trymany=false)#delta=framedistance;isb=IS Backward # Looks 1 frame ahead and calculates vectors backward to reference frame. forw_vec=MAnalyse(super, blksize=blksz, search=5, searchparam=searchp, isb=false, delta=1, temporal=false, dct=0, divide=0, trymany=false)#search 3:=Exhaustive; 4:=Hex(default); 5:=UMH # Looks 1 frame behind and calculates vectors forward to reference frame. dblback_vec=MAnalyse(super, blksize=blksz, search=5, searchparam=searchp, isb=true, delta=2, temporal=false, dct=0, divide=0, trymany=false)#delta=framedistance;isb=IS Backward # Looks 2 frames ahead and calculates vectors backward to reference frame. To be used when reference frame + 1 has to be excluded. dblforw_vec=MAnalyse(super, blksize=blksz, search=5, searchparam=searchp, isb=false, delta=2, temporal=false, dct=0, divide=0, trymany=false)#search 3:=Exhaustive; 4:=Hex(default); 5:=UMH # Looks 2 frames behind and calculates vectors forward to reference frame. To be used when reference frame -1 has to be excluded. global fillsingdrops = MFlowInter(c,super,back_vec,forw_vec,time=50, blend=bld, thSCD1=SCDpb, thSCD2=SCDpf) global filldoubdrops33 = MFlowInter(c,super,dblback_vec,dblforw_vec,time=33, blend=bld, thSCD1=SCDpb, thSCD2=SCDpf) global filldoubdrops67 = MFlowInter(c,super,dblback_vec,dblforw_vec,time=67, blend=bld, thSCD1=SCDpb, thSCD2=SCDpf) global oric=c global devthresh=dev #ConditionalFilter(c, c, fillsingdrops, "YDifferenceFromPrevious()", ">", "devthresh", show=true)##works for mending of single framerepeats #ConditionalFilter(c, c, filldoubdrops33, "YDifferenceFromPrevious()>devthresh", "&&", "YDifferenceToNext()>devthresh", show=true)##wrong syntax c.scriptclip("""(YDifferenceFromPrevious<devthresh) && (YDifferenceToNext<devthresh) ? (filldoubdrops33++filldoubdrops67.Trim(1,0)) : (YDifferenceFromPrevious<devthresh) ? fillsingdrops : oric""") }
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain) "Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..." Last edited by Emulgator; 13th April 2014 at 17:07. |
13th April 2014, 20:44 | #7 | Link | |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
Quote:
PS: How to deactivate those annoying random questions? |
|
13th April 2014, 20:58 | #8 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
MSuper is part of MVTools; there's a patched build in Dither tools.
Be aware that unless you do some munging with variable frame rates (which is not recommended unless you really know what you're doing), there will be judder if you don't remove the duplicate frames prior to motion interpolation. I assume the annoying questions go away after you hit some arbitrary post count; some other forum posters I asked said they didn't see the questions at all. Edit: To make this work with one of the filldrops functions (without judder), you'd need to make the group of three identical frames a group of only two identical frames. (filldrops3 looks like it was designed to handle such groups of three, but that is not the right thing to do in this case.) TDecimate(mode=1) does exactly that, getting rid of the third frame. The script you use should be something like: Code:
source TDecimate(mode=1) # so instead of an AABBB pattern, you have AABB filldrops3() Code:
source SelectEven().TDecimate() super = MSuper(last) vecb = MAnalyse(super,isb=true) vecf = MAnalyse(super,isb=false) MFlowFps(last,super,vecb,vecf,num=30,den=1,blend=false) # replace num/den with the desired output frame rate Last edited by colours; 13th April 2014 at 21:23. Reason: elaborate on judder |
13th April 2014, 23:42 | #10 | Link |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
I was wrong. filldrops3 does well at dropping cloned frames, but it does not interpolate between them. So what I got was 30fps while those 30fps are the previous pictures minus the cloned ones, so it is way faster.
Now I have this code Code:
DirectShowSource("13. April 2014, 082538.AVI") ConvertToYV12() SelectEven().TDecimate() super = MSuper(last) vecb = MAnalyse(super,isb=true) vecf = MAnalyse(super,isb=false) MFlowFps(last,super,vecb,vecf,num=30,den=1,blend=false) # replace num/den with the desired output frame rate Last edited by Kim Brandstetter; 13th April 2014 at 23:50. |
14th April 2014, 04:17 | #12 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Quote:
Code:
super=MSuper(pel=1, hpad=0, vpad=0) backward_1=MAnalyse(super, chroma=false, isb=true, blksize=16, blksizev=16, searchparam=3, plevel=0, search=3, badrange=(-24)) forward_1 =MAnalyse(super, chroma=false, isb=false, blksize=16, blksizev=16, searchparam=3, plevel=0, search=3, badrange=(-24)) backward_2 = MRecalculate(super, chroma=false, backward_1, blksize=8, blksizev=8, searchparam=0, search=3) forward_2 = MRecalculate(super, chroma=false, forward_1, blksize=8, blksizev=8, searchparam=0, search=3) MBlockFps(super, backward_2, forward_2, num=num, den=den, mode=0) should get rid of weird swirly stuff.
__________________
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; 14th April 2014 at 16:59. |
||
14th April 2014, 04:23 | #13 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
First arrow is SelectEven, second is TDecimate (assuming it picks the correct frames).
AAABBCCCDD → AABCD → ABCD ABBBCCDDDE → ABCDD → ABCD AABBBCCDDD → ABBCD → ABCD ABBCCCDDEE → ABCDE → ABCD or BCDE (note that A/E are duplicates across groups of five) AABBCCCDDE → ABCCD → ABCD The increased accuracy comes from nuking five sixths of the dupes in each ten-frame section without even needing to detect which frames are duplicates. The pattern change transitions might not be handled exactly, but stepping through the video to manually handle these is rather time-consuming. Kim Brandstetter: You might also want to check if it's DirectShowSource causing the artifacts if StainlessS' suggestion doesn't help. Not likely, but it's not something to overlook. |
14th April 2014, 17:05 | #15 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
If the weird distortions you wrote of are sort of 'swirly', then MBlockFps instead of MFlowFps may get rid. EDIT: The previously posted MBlockFPS script is product of some Avisynth wizard, not mine, dont recall where I got it but it does generally produce less artifacts than the script snippet it replaces.
__________________
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; 14th April 2014 at 18:37. |
|
14th April 2014, 19:12 | #16 | Link |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
It is still juddering and disappointing.
So a general question: what can I expect from frame generation 12 fps -> 30 fps? 30 fps -> 60 fps is great but 12 fps -> 30 fps is not. Anybody can offer samples? Last edited by Kim Brandstetter; 14th April 2014 at 19:48. |
14th April 2014, 19:42 | #17 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I think it likely that 12fps -> 24fps would be somewhat better than 12fps -> 30fps, the amount of movement
between frames at 12fps will be quite large and is asking rather a lot to smoothly generate flaw free video at 30fps. The smaller movement differences between frames at 30fps make it much easier to 'guess' tweened frames to produce 60fps (it's also an exact multiple). I've read good thinks about SVP but have never tried it. Is 30fps an absolute requirement ?
__________________
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 ??? |
14th April 2014, 19:43 | #18 | Link | |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
Quote:
|
|
14th April 2014, 19:45 | #19 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Try 24fps, see if that is bearable.
__________________
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 ??? |
14th April 2014, 20:34 | #20 | Link | |
NSA Agent
Join Date: Dec 2011
Location: Classified data
Posts: 20
|
Here's a testfile:
Quote:
Last edited by Kim Brandstetter; 14th April 2014 at 21:00. |
|
|
|