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.

 Doom9's Forum Using avisynth for special interpolation
 User Name Remember Me? Password
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes
13th April 2014, 01:48   #1  |  Link
Kim Brandstetter
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:
 1. Movie picture 2. Clone of previous movie picture 3. Movie picture 4. Clone of previous movie picture 5. Clone of previous movie picture 6. Repeat from 1
equals

Quote:
 AABBBCCDDDEEFFFGGHHH.... where A = first frame B = second frame C = third frame D = ...

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:
 Movie picture 1 Morph/other transition method* between Movie picture 1 and Movie picture 2 Movie picture 2 2 frames Morph/other transition method between Movie picture 2 and Movie picture 3 Movie picture 3 Morph/other transition method between Movie picture 3 and Movie picture 4 Movie picture 4 2 frames Morph/other transition method between Movie picture 4 and Movie picture 5 Movie picture 5 Morph/other transition method between Movie picture 5 and Movie picture 6 Movie picture 6 2 frames Morph/other transition method between Movie picture 6 and Movie picture 7 Movie picture 7 etc.

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:13 #2  |  Link Guest Guest   Join Date: Jan 2002 Posts: 21,922 SelectEvery(5,0,2). Then convert frame rate as needed using your favorite method. The local Avisynth Gods will arrive shortly, I suppose. Last edited by Guest; 13th April 2014 at 02:16.
 13th April 2014, 02:56 #3  |  Link Kim Brandstetter 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 Guest   Join Date: Jan 2002 Posts: 21,922 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 colours 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 Emulgator Big Bit Savings Now !     Join Date: Feb 2007 Location: close to the wall Posts: 984 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", show=true)##works for mending of single framerepeats #ConditionalFilter(c, c, filldoubdrops33, "YDifferenceFromPrevious()>devthresh", "&&", "YDifferenceToNext()>devthresh", show=true)##wrong syntax c.scriptclip("""(YDifferenceFromPrevious
13th April 2014, 20:44   #7  |  Link
Kim Brandstetter
NSA Agent

Join Date: Dec 2011
Location: Classified data
Posts: 20
Quote:
 Originally Posted by Emulgator You may try filldrops123.avsi Copy, paste, rename as filldrops123.avsi, put it into your plugins folder and call function as filldrops3. --------------------------------------- Code: `super=MSuper(c,pel=2)`
Thanks. MSuper is missing though.

PS: How to deactivate those annoying random questions?

 13th April 2014, 20:58 #8  |  Link colours 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()``` But then you might run into issues with multiple duplicate frames being detected etc., and the best option is just to decimate to 12 fps first. 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, 21:07 #9  |  Link Kim Brandstetter NSA Agent     Join Date: Dec 2011 Location: Classified data Posts: 20 It works now. This is just amazing. Thanks to all of you for your quick support. EDIT: See below. Last edited by Kim Brandstetter; 13th April 2014 at 23:50.
 13th April 2014, 23:42 #10  |  Link Kim Brandstetter 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``` But that creates a weirdly distorted video with artefacts all over the place. Also, I get 0.92 fps rendering time in virtualdub, which is bad. Last edited by Kim Brandstetter; 13th April 2014 at 23:50.
13th April 2014, 23:47   #11  |  Link
Richard1485
AviSynth monkey

Join Date: Feb 2010
Posts: 398
Quote:
 Originally Posted by colours 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).
I understand the first option but not the second. Might changes in the pattern not cause problems if at some point SelectEven() discards a frame that is not duplicated? I'm just curious.

14th April 2014, 04:17   #12  |  Link
StainlessS
HeartlessS Usurer

Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,035
Quote:
 Originally Posted by Kim Brandstetter 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```
Quote:
 creates a weirdly distorted video
Perhaps try replace stuff in blue
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)```
EDIT: replace num=30, den=1

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 colours 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, 09:30   #14  |  Link
Richard1485
AviSynth monkey

Join Date: Feb 2010
Posts: 398
Quote:
 Originally Posted by colours The pattern change transitions might not be handled exactly, but stepping through the video to manually handle these is rather time-consuming.
Ah! So you're accepting a trade off: an overall increase in accuracy set against the risk of not handling some pattern changes exactly. Thanks for the explanation. Apart from that, I more or less saw what you were doing.

14th April 2014, 17:05   #15  |  Link
StainlessS
HeartlessS Usurer

Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,035
Quote:
 Originally Posted by colours You might also want to check if it's DirectShowSource causing the artifacts
Yep, DirectshowSource can cause blending and other anomalies depening upon how it is set up (eg does AUTO deinterlace, inverse telecine + more), use AviSource or other, DirectShowSource only if nothing else works.

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 Kim Brandstetter 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 StainlessS HeartlessS Usurer     Join Date: Dec 2009 Location: Over the rainbow Posts: 9,035 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
Kim Brandstetter
NSA Agent

Join Date: Dec 2011
Location: Classified data
Posts: 20
Quote:
 Originally Posted by StainlessS 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 ?
12 fps is almost unbearable.

 14th April 2014, 19:45 #19  |  Link StainlessS HeartlessS Usurer     Join Date: Dec 2009 Location: Over the rainbow Posts: 9,035 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
Kim Brandstetter
NSA Agent

Join Date: Dec 2011
Location: Classified data
Posts: 20
Here's a testfile:
Quote:
 http://www.mediafire.com/watch/durwstuwhk0b0dz/14._April_2014,_095208.AVI
Why don't you get the file and apply your ideas to it to tell me what works best?

Last edited by Kim Brandstetter; 14th April 2014 at 21:00.

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding     VP9 and AV1 (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD & BD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 16:09.

 Doom9.org - Archive - Top