PDA

View Full Version : Using deinterlaced Upper and Lower Field to blend for better Motionblur w. TomsMoComp


freezer
16th August 2005, 16:39
Hi all!

I am working on an independet austrian movie called "JENSEITS" (="BEYOND").
We are using a Canon XM-2 with an anamorphotic adapter to get the best out of 16:9 miniDV. You can check our teaser 1 (http://www.loom.at/download/jenseits/Jenseits_Teaser_1_640x360.avi) and teaser 2 (http://www.loom.at/download/jenseits/Jenseits_Teaser_2_640x360.avi) if you are interested.

My current workflow:

Capturing the clips with Premiere 1.5 and exporting the final cut to DV AVI.
Deinterlacing with AviSynth and exporting to PicVideo v3 AVI.
Color grading and compositing in AfterFX 6.5 and exporting to PicVideo v3 AVI.


Recently I learned there is a method to deinterlace once with upper fields first and once with lower fields first and then combining both with a transparency of 50%. I was able to do this with AfterFX, where you just load the AVI two times and set the interpretation to upper and lower fields. Then you combine them with the upper fields layer set to 50% transparency.
This gives me a much smoother and more filmalike looking picture. It also reduces noise a bit.
Method is described in this article (http://www.dvinfo.net/articles/filmlook/broadway1.php).

But to get the maximum quality possible, I want to do this in AviSynth.

So far I have used this script for deinterlacing:

TomsMoComp(0,5,0) # Deinterlace
Unfilter(0,-15) # Vertical filtering
ConvertToYV12()

# EDGE SMOOTHING
# Upsize the Source ...
Lanczos4Resize(720, 1152)
# Grab off-setting pixels(?) ...
top = SangNom(order = 0)
btm = SangNom(order = 1)
# Overlay the offset images on top of each other ...
top.overlay(btm, opacity = 0.5)
# Resize back down to native resolution ...
Lanczos4Resize(720, 576)

LimitedSharpen(ss_x=2.0, ss_y=2.0, Smode=3, strength=400)
ConvertToYUY2()

My question is how can I do the same procedure with AviSynth and TomsMoComp like in AfterFX?
I have tried around but it gets only a worse picture then intended.

I hope someone more skilled than me can help me out.

Thanks for reading so far :)

EDIT:
Ups, sorry chose the wrong forum - this wasn't intended to end in the developer forum.

Mug Funky
16th August 2005, 16:57
hang about... you'd get the same effect faster by just using blur(0,1)... or kassandro's "alignfields" which is a blend deinterlacer (all kassandro's plugins are very optimised, so it'll probably be just as fast).

motion will be smoother with this method, but it'll never look like film - the shutter speeds are all wrong. a video camera set to 1/50 per field and blended will give you _almost_ the same effect as shooting with an exposure of 1/25, which film cameras just can't do - there's some time where the shutter has to close and open again, meaning the motion-blur from a film camera is shorter than that of a blend-deinterlaced video frame, but longer than that of a single 1/50th field.

one way to get real filmlike stuff is with a motion-blur filter and a _really_ good deinterlacer (tdeint or tomsmocomp with a comb-mask) to keep as much detail as possible. the motion-blur filters are very slow and prone to blocking though...

really, a single-field deinterlace combined with your anamorphic adapter and some good lighting/shooting will give the best filmlook possible without going into impractical solutions like motion-compensated blurs etc. there's also a film look specific thread on this forum which gives some ideas. with after effects you should be able to get some good stuff going. there's also motion-blur plugins for that (look at the Twixtor package... it does motion blur plus loads more).

[edit]
Capturing the clips with Premiere 1.5 and exporting the final cut to DV AVI.

hehe... watch you don't get dropped frames. for some reason premiere 6.5 caps with less overhead than pro 1.5 (and it's still way too much). if you use scenalyzer or something like that you can capture in the background while you browse the web :) no dropped frames unless you're trying to defrag at the same time :p

btw, good luck with your project. we need more ideas in film, and they sure aren't coming from hollywood.

scharfis_brain
16th August 2005, 17:04
rule No.1 Mugfunky already mentioned:
shoot with 1/50 sec shutter. It is the same shutter, that film commonly is shot in.
Film is commonly exposed to light half the time the frame gets displayed later.
ie: 24 fps -> 1/24 sec per frame -> 1/48 sec shutter.

if you've shot with shorter shutter, blending two fields together won't produce motionblur. It will produce Ghosting!

Instead of blending frames together, one needs to apply a motion compensated motion blurrer, like mvfps() can do.

The currently best deinterlacing quality can be achieved with mvbob().
But be warned: mvbob() and mvfps() sloooooooooooooooow.

EDIT: I assume that you are working with PAL devices....

Wilbert
16th August 2005, 17:07
1) Are you sure you want to convert it to 24p? Anyway, here's a tutorial: http://aqua-web.dyndns.org/avisynth_24p.php

2) It shouldn't be necessary to create an intermediate PicVideo v3 AVI for AviSynth->AfterFX 6.5. Look for an avi-wrapper called makeAVIS.

Bester
16th August 2005, 17:15
I know some people don't like blending, but I'm really into.

I often use Overlay(clip,clip,y=1,opacity=0.5), perhaps combined with a mask.
this method gives a much sharper image than blur(0,1),
reduces noise and all the nasty problems with diagonal lines and interpolation don't appear.
And it's fast and compresses very good and...

scharfis_brain
16th August 2005, 17:30
all the nasty problems with diagonal lines and interpolation don't appear.

I cannot agree:
- residual combing
- much heavier stairstepping than blur(0,1)

But I am still interested, what this line does really...

Pookie
16th August 2005, 17:33
Nice looking video clips ! :)

I love LimitedSharpen , but isn't strength=400 a bit much ? If you need that much sharpening, use kassandro's Rsharpen plugin, located at

http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar

Try Rsharpen(mode=3) It is FAST, and works quite well.

freezer
16th August 2005, 20:11
scharfis_brain wrote:
rule No.1 Mugfunky already mentioned:
shoot with 1/50 sec shutter. It is the same shutter, that film commonly is shot in.
Film is commonly exposed to light half the time the frame gets displayed later.
ie: 24 fps -> 1/24 sec per frame -> 1/48 sec shutter.

if you've shot with shorter shutter, blending two fields together won't produce motionblur. It will produce Ghosting!


Don't worry, we used a shutter speed of 1/50th for the whole movie. Which is pretty close to 1/48 of film cameras.
I did a lot of research before starting filming (which we actually did for 74 days).
And you are right, we are working in PAL 720x576 anamorphic.

mug funky wrote:
hang about... you'd get the same effect faster by just using blur(0,1)... or kassandro's "alignfields" which is a blend deinterlacer (all kassandro's plugins are very optimised, so it'll probably be just as fast).

one way to get real filmlike stuff is with a motion-blur filter and a _really_ good deinterlacer (tdeint or tomsmocomp with a comb-mask) to keep as much detail as possible. the motion-blur filters are very slow and prone to blocking though...

really, a single-field deinterlace combined with your anamorphic adapter and some good lighting/shooting will give the best filmlook possible without going into impractical solutions like motion-compensated blurs etc. there's also a film look specific thread on this forum which gives some ideas. with after effects you should be able to get some good stuff going. there's also motion-blur plugins for that (look at the Twixtor package... it does motion blur plus loads more).

We did take care a lot for lighting for film. I have already followed the film look thread, which is not my problem, as I can take care of this easily in AfterFX.

I already did some testing with the AfterFX way described above and compared it to a standard deinterlaced version. And we liked the smoother looking version much more.
I don't really want to use the blur() method, but already played around with overlay(), but I couldn't work out a way with TomsMoComp.

scharfis_brain
16th August 2005, 21:21
hmm. in your trailers I could not find a single 1/50 sec shutter sequence.
All had been done with a shorter shutter....

freezer
16th August 2005, 22:15
You can trust me: they are all definately 1/50 sec shutter sequences. I would like to know how you can tell that from looking to the teasers? They have been deinterlaced with the script I mentioned above.

Bester
17th August 2005, 00:10
But I am still interested, what this line does really...

Some pics:

http://x1.putfile.com/8/22716521025.jpg orig
http://x1.putfile.com/8/22716531099.jpg separatefields().lanczos4
http://x1.putfile.com/8/22716501532.jpg greedyhma
http://x1.putfile.com/8/22716534936.jpg tomsmocomp
http://x1.putfile.com/8/22716575224.jpg overlay

greedy gives good results and i like it much. but the line looks best
with overlay and it is also very hard to mask such lines out, espesially form vhs.
-------------------------------
I really can't see combing in my videos with overlay. :confused:
stairstepping is no problem for me, if it is also in the orig source.
blur(0,1) reduces that but wahes out the picture.

I also like your mvbob(), but unfortunately it is not much practical

scharfis_brain
17th August 2005, 00:21
@Bester:
ever tried TDeint?

I have a all purpose stress-test video for deinterlacers. Which showed residual combing with the overlay line.

@Freezer:

1/50 shutter means that motion blur is half as long as the duration of the frame for deinterlaced PAL-Video.

Hmm. okay. it seems that I was wrong. there are scenes with 1/50 sec shutter. but there are scenes with shorter shutter, too! (speedup?)
Hmm. maybe I was being distracted too much, while watching your clips so I did a wrong assumption.

So I suggest this - if rendering time doesn't matter:

reinterpolate420() # if you are using DV.
mvbob()
selecteven()

for a two times slowmotion you may want to set the shutter to 1/100 sec and use this script:

reinterpolate420() # if you are using DV.
mvbob()
assumefps(25,true).ssrc(48000)

mvbob will noticeably reduce noise (without smearing) and deinterlacing artifacts like stairstepping and flickering while enhancing image detail.
But be warned: max. 2 fps rendering speed on my 1,4 GHz Athlon.

I think, that you are already doing this, but I like to say it anyway:
Apply this processing before editing. Not afterwards.

freezer
17th August 2005, 02:04
Oh yeah - you are right - there are some speedup scenes e.g. the one where the camera moves toward the screaming guy in the woods. And the camera crane move to the old house, too. Didn't think about that. I intentionally did not use the blend mode of premiere, because it blurred too much.

2fps? Hey, my script got 4fps on my Postpro Pentium 4 /3,4 GHz, so I guess I won't see much degradiation in speed :)
I will give mvbob() a shot.

Bester
17th August 2005, 11:43
I have a all purpose stress-test video for deinterlacers. Which showed residual combing with the overlay line.

Could you please make that available, I'm very interested!

scharfis_brain
17th August 2005, 11:58
here it is:
http://www-e.uni-magdeburg.de/drobek/doom9.avi

It has everything to test a deinterlacer:
- rainbow
- dotcrawl
- noise
- ultra crisp static subtitles
- fine moving low contrast detail
- patterned moving structures that fool motion detection

Bester
17th August 2005, 13:07
Ahh, the famous japanese girl!

:thanks: I'm testing a little bit this evening. The video not the girl.... :p

freezer
17th August 2005, 15:09
@ scharfis_brain

took me the whole night to get the mvbob() up and running - it even managed to kill avisynth - it couldn't load even a simple directshowsource() script... Had to reinstall the whole thing, don't know what happend.
It also would be a good idea, if the scripts would be better collected, so you always can be sure to have the latest version of all necessary things. It took me a few hours to skip through the threads, find all scripts and plugins...
I think there should be a better way to make those things available, than scattering infos around one or more long threads here.

Anyway one more question:
Which modifications have to be done to the script, if I would like to overlay the even and odd parts of mvbob, instead of just skipping the odd ones?

scharfis_brain
17th August 2005, 18:22
there is a mvbob-package in this mvbob-thread.
http://home.arcor.de/scharfis_brain/mvbob/mvbob.rar

As we said before: blending two fields together is NOT a good idea, because it does not simulate filmlike motion blur.
Doing so would return a 1/25 sec shutter per Frame which means that the motionblurs are touching each other from frame to frame.

anyway - I do not recommend it - here it is:

x=mvbob()
y=x.trim(1,0)
x.mergeluma(y,0.5).mergechroma(y,0.5)
selecteven()

Bester
18th August 2005, 10:41
@ scharfis_brain.

Your vid is really tuff. But I cannot see combing, especially if you watch it.
Could you please point me where you notice combing.

http://rapidshare.de/files/4101894/orig-overlay.avi.html (xvid, 6.5 MB)

scharfis_brain
18th August 2005, 12:12
frame:
136: bottom right
194: the pencils
etc.


btw.: why has your sample 25 fps?
and what means "tuff" ?

Bester
18th August 2005, 13:14
Seems I lost :(
You are the master!

tune-up-for-feed

:thanks:

freezer
18th August 2005, 19:08
Ok, I managed to work out a script for me, based on scharfis_brain's script.
The new deinterlacer makes less strange "spiderweb" artifacts e.g. to trees in front of the sky. Also played with a few other scripts from this forum, but at last I stayed with mvbob(), overlay() and LimitedSharpen.

SetMemoryMax(256)
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\kerneldeint.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\ReInterpolate411.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\UnDot.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\MipSmooth.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\SmoothHiQ.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\TomsMoComp.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\UnFilter.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\MaskTools-p4-5.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\FastEDIUpsizer.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\SangNom.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\TDeint.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\rawsource.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\warpsharp.dll")
LoadPlugin("c:\Programme\AviSynth 2.5\plugins2\aWarpSharp.dll")

Import("c:\Programme\AviSynth 2.5\plugins2\LimitedSharpen.avs")
Import("c:\Programme\AviSynth 2.5\plugins2\reinterpolate420.avs")
Import("c:\Programme\AviSynth 2.5\plugins2\mvbob.avs")

DirectShowSource("V:\JENSEITS\Film\Epilog\Zugeschnitten_Jenseits Film - Gegenwart\Epilog Szene 69-1 David erblickt Sensenmann.avi")

reinterpolate420()
clip_full=mvbob()
clip_lower=clip_full.selecteven()
clip_upper=clip_full.selectodd()
Overlay(clip_lower, clip_upper, mode="blend", opacity=0.33)
LimitedSharpen(ss_x=2.2, ss_y=2.2, Smode=1, strength=400)

Just wanted say thanks to all!

freezer
18th August 2005, 21:08
Hmm, just found the weak spot of mvbob():
camera moves with a simple (not fullrig) steadycam are a big problem...
motion towards the actor with slight rolling and up and downshaking seems to be a big no-no

scharfis_brain
19th August 2005, 01:43
hmm. could you supply a sample showing this mvbob-weakness?

why are you sticking to the overlay technique? As it does NOT simulate a film-like motion.
one field is enough for get the film like motion.
The page regarding motion blur you did mention with your initial post was for NTSC-footage and not for PAL-video.
Besides this, that page is not fully correct...

Also, I thinke that your Limitedsharpen strenght is FAR too much.
The samples showed it clearly. It looked like an oil painting.

Please do not fall into a mode of 'filteritis'.

freezer
19th August 2005, 08:17
I will try to provide an example. The oil painting effect came from the sangnom edge removing process in my first script and was increased by LimitedSharpen's sMode 3. Now I am using sMode 1, which is much less prone to this effect.

kassandro
19th August 2005, 10:05
I am now watching this thread for quite a while. Two topics force me to enter the discussion. Firstly, scharfis_brain repeated bashing of blending. Secondly, his bold claim

here it is:
http://www-e.uni-magdeburg.de/drobek/doom9.avi

It has everything to test a deinterlacer:
- rainbow
- dotcrawl
- noise
- ultra crisp static subtitles
- fine moving low contrast detail
- patterned moving structures that fool motion detection

It totally ignores several fundamental aspects (and some more about which I omitt here). Firstly the threshold disease. If the temporal change of a pixel (and its spatial neighbours) is above a certain threshold the pixel is interpolated otherwise it is left unchanged. (Leak)kerneldeint and Fielddeinterlace are such deinterlacers. Now if you have two adjacent pixels, one slightly above the threshold and the other slightly below, then you have a typical threshold artifact. The two pixels, which may have had very simialar values before may have very different values afterwards. Most of the time such threshold artifacts are hardly visible, but from time to time they become quite ugly. On the other hand, even when they are invisible the threshold artifacts have a very negative impact on compression. That is the key reason, why the above deinterlacers perform so poorly in compression tests with reasonable thresholds to keep static detail. TDeint has more sophisticated motion masks. Instead of only two alternative (interpolate or change nothing), it has motion masks with about four alternatives (spatial interpolation, temporal interpolation, pixels from the current frame, pixels from the previous or subsequent field). While this is certainly a lot better than the crude binary masks of the above two deinterlacers, it suffers from threshold disease as well. Unfortunately the threshold disease cannot be shown with a clip, because it depends on the chosen thresholds. By slightly changing the threshold visible threshold artifacts disappear in one clip while they come to life in another clip.
The second fundamental aspect concealed by scharfis_brain is compression. Why are we deinterlacing in the firstly place? The primary argument is that progressive encoding is more compression efficient than interlaced encoding and from this point of view deinterlacers suffering from the threshold disease are not acceptable. These deintelacers usually do not suffer only from the threshold disease, they suffer from field imbalance (also concealed by scharfis_brain) as well. At first glance, it looks great to change only one field, but as a consequence one field is smoother than the other and this is not very DCT friendly. Furthermore the motion compensation of the codec has problems with field imbalance. Altogether, field imbalance has an additonal negative effect on compression.
Blending certainly does not suffer from field imbalance, because both fields are treated equal. However, motion detail gets lost. Usually blending produces motion blur, which is very good for compression. In exceptional cases (fast shutter speed + fast motion) one can get ghosts, which are certainly not compression friendly but not a desaster either. The rule of thumb is that if the motion is already slightly unsharp on the fields, then blending produces good motion blur and not ghosts. Furthermore one can tilt a deinterlacer towards motion blur, by blurring not only vertically but also horizontally, which is very DCT friendly as well. In this way ghosts don't play a role in 95% of all interlaced videos. However, what can we do with the remaining 5%. Firstly, interlaced encoding is a very good choice for these videos, but if compression is a dominant issue, one still wants to blend. Can blending be done without ghosting? I would think that it can be done. TDeint's motion masks may be one direction to solve this problem, but, as I said earlier, this approach suffers from the threshold disease. Rather I will go along the way of my TemporalRepair(smooth=2), which I currently use to make simple spatial deinterlacers like blur(1) or blur(0,1) motion adaptive without suffering from the threshold disease. It passes scharfis_brain's residual combs test, but clearly doesn't remove ghost produced by blur(0,1) or blur(1) (which are less likely). I have a not yet implemented idea to cope with ghosts as well. However, it is not yet clear, whether this sophisticated version of TemporalRepair leaves some resiudal combs.
I should mention that TomsMoComp does not suffer from the threshold disease. TomsMoComp(x,x,0) suffers from field imbalance TomsMoComp(x,x,1) does not.


hang about... you'd get the same effect faster by just using blur(0,1)... or kassandro's "alignfields" which is a blend deinterlacer (all kassandro's plugins are very optimised, so it'll probably be just as fast).

I have abandoned AlignFields for quite a while and don't use it any more. There were two reasons for AlignFields. Firstly smooth motion masks avoiding the threshold disease (I could do this now much better with the mask tools), secondly a spatio-temporal blending method, which, however may produce even two ghosts. If I am successfull with the above very special version of TemporalRepair, I will resurrect AlignFields. It will contain this special version of TemporalRepair and spatio-temporal blurring.

One final remark about scharfis_brain's "ultra crisp static subtitles". A deinterlacer should not keep these subtitles crisp, because they are surrounded by motion. In such a case any codec with reasonable quant will destroy the crispness and even creat edge flicker. Thus it is better if deinterlacers soften the edges of these subtitles to prevent the codec from doing even more harm.

scharfis_brain
19th August 2005, 10:54
kassandro, you've misundorstood the intention of deinterlacing here: making filmlike motion.
This has NOTHING to do with compression in first place and also doesn't permit blending. I wanted to help this guy to get the best out of his sources. I did not wanted to say: hey: 'blur(1) is everything you need'.

I dislike that you are mirroring EVERY filtering attempt to compression. It simply doesn't make sense. We are in the era of DVD-making, thus meaning bitrates up to 9 Mbps for Video only!

Uhm, yeah, smooth out static parts, why should one do so? Just to help compression a little bit? NO!

With my filters I try to squeeze out every bit of detail, so every blending, exept for static-blending is forbidden. (Try to upsample SDTV -> HDTV with blur-deinterlaced sources... No a good idea...)
Tdeint and mvbob are doing static-area blending already...
With slight comb-leftovers from a threshold of six I can live without problems.
with mvbob these are prevented most time, because it moves the preceding and following field towards the actual ane.

And the field-balance you mentioned is not a matter either for me.
(Just look at cheap TV-productions. They are always throwing away ONE full field, but I've never seen blending there!)

Long Story short: With my deinterlacing attemts I try best to restore a (non-exsistant) progressive master. (can be nicely simulated)
You are trying to blur it to give it more compressibility.
Two different point of views. I will not change mine.

kassandro
19th August 2005, 15:50
kassandro, you've misundorstood the intention of deinterlacing here: making filmlike motion.

If I didn't misunderstand, the thread starter, he did want to convert 25 fps interlaced into 25 fps progressive. That is classical deinterlacing. He was probably dissatisfied with the jerky motion, which he got from a sharp deinterlacer and did ask specifically for motion blur. He never did want 50 fps progressive nor did he want to preserve a maximum amount of detail. I admit, that he wasn't interested in compression either. You did rightly point out, that he might get ghosts instead of the desired motion blur. In response, you made some general claims about deinterlacers.


This has NOTHING to do with compression in first place and also doesn't permit blending. I wanted to help this guy to get the best out of his sources. I did not wanted to say: hey: 'blur(1) is everything you need'.

He doesn't want to "to get the best out of his sources." Instead he wants smooth progressive motion at 25 fps and you can only achieve this with blending.


I dislike that you are mirroring EVERY filtering attempt to compression. It simply doesn't make sense. We are in the era of DVD-making, thus meaning bitrates up to 9 Mbps for Video only!

I know your opinion very well.


Uhm, yeah, smooth out static parts, why should one do so? Just to help compression a little bit? NO!

I never advocated blurring static parts and I never will. Instead I talked a lot about various types of motion masks or my TemporalRepair, which all about preserving static detail. In fact, as far as static detail is concerned we do agree: we both want to preserve as much static detail as possible. However, the thread starter and I do not want to preserve as much motion detail as possible. The thread starter wants smooth motion and in addition I want good compression.


With my filters I try to squeeze out every bit of detail, so every blending, exept for static-blending is forbidden. (Try to upsample SDTV -> HDTV with blur-deinterlaced sources... No a good idea...)

Yes, for this task blending is not the way to go, but neither the thread starter nor I have this task.


And the field-balance you mentioned is not a matter either for me.
(Just look at cheap TV-productions. They are always throwing away ONE full field, but I've never seen blending there!)

May be, that I watch "cheap TV-productions", but I don't know any tv production which throws away fields an reinterpolates them, even the infamous compulsory pay tv provider ARD doesn't do such things and they do a lot of things to harass viewers.


Long Story short: With my deinterlacing attemts I try best to restore a (non-exsistant) progressive master. (can be nicely simulated)
You are trying to blur it to give it more compressibility.
Two different point of views. I will not change mine.
If you would say "trying to blur motion" instead of "trying to blur" I would agree.

freezer
19th August 2005, 16:46
If I didn't misunderstand, the thread starter, he did want to convert 25 fps interlaced into 25 fps progressive. That is classical deinterlacing. He was probably dissatisfied with the jerky motion, which he got from a sharp deinterlacer and did ask specifically for motion blur. He never did want 50 fps progressive nor did he want to preserve a maximum amount of detail. I admit, that he wasn't interested in compression either. You did rightly point out, that he might get ghosts instead of the desired motion blur. In response, you made some general claims about deinterlacers.

Hmm, you're both not totally right.
The movie will be played in a movie theatre, which means it will be projected very large, approximately 6 to 10 meters wide. That means I want to preserve the most of the details I can get with the most filmic look I can receive. In Europe it is no problem to play a movie with 25 fps, so I don't have to go for 24 fps. Compressabilty is absolutely not interesting - I simply want the maximum quality I can receive from my source. Neither is time for rendering a problem.

I did now manage to upscale my source to 1280x720 using iip and the GrainFactory, which gives me a very pleasing picture on my 24" Computer TFT (1920x1200), so I think this will be the way to go for the movie premiere.
I know the upscale won't give me any details, but together with the simulated grain it looks much better than the anamorphic 16:9 alone. I could then use the PC to feed the digital projector directly, which should result in the best picture I can get.

Btw, I did some experiment with AfterFX (1280x720px), where I made a 3D-ball in Photoshop (100 pixels diameter) and let it move from x=-100 to x1380 in AFX. I made two compositions, one with 24 fps progressive and one with 25 fps interlaced. Then I activated the motionblur for both with a shutter of 180° (= 1/48s and 1/50s) and rendered them.
Then I imported the interlaced clip and used AFX to deinterlace. And guess what? The motionblur was only half of the length of the 24fps progressive clip.

scharfis_brain
19th August 2005, 16:55
The motionblur was only half of the length of the 24fps progressive clip.

The software worked totally correct.

24p -> 180° shutter -> 1/48 sec shutter
25i == 50 half-fps-> 180°shutter -> 1/100 sec shutter.
for video you must set to full shutter...


note:
- Video 360° or 'full' shutter
- Film commonly 180° or half shutter.

so, for PAL, if you deinterlace the video, Film and Video do share the same length of motion blur.


I hope, you now see, that blending two (bob-deinterlaced) fields together will not result in a filmlike effect.


Can you provide that sample and your current script, please?

Mug Funky
26th August 2005, 12:50
May be, that I watch "cheap TV-productions", but I don't know any tv production which throws away fields an reinterpolates them

live music... even on TV shows that are natively interlaced, for some reason they think it's a really good idea to just ditch the odd fields, and duplicate the even fields (half-line of black at the top and all) when a band starts playing. i haven't a clue why they do this, but the effect is quite distinctive and VERY annoying to watch.

i only know of examples on australian TV of course, but "rove" (on the music parts) and "home and away" (in fact a lot of channel 7 dramas), and "skithouse" all have the ugly field-duplication deinterlace (even their sodding DVD master had this! wtf are you supposed to do with footage like that... our AV testers were complaining that it looked jerky and "wrong", but of course it's not our fault).

MVbob is about the best deinterlacing for film anyone's likely to get without a ludicrously expensive rig, like something from snell and wilcox.

btw, the threshold noise is easily solved by horizontally expanding the comb mask... the standards converter here does it that way - it'll deinterlace about 5 pixels horizontal radius from the actual combed areas. this also helps on moving blurry things, which can leave strange bright edges behind with spatial comb masks.

o2xygen
27th August 2005, 00:11
there is a mvbob-package in this mvbob-thread.
http://home.arcor.de/scharfis_brain/mvbob/mvbob.rar


@scharfis
I am using your script mvbob.avs

#Helper functions:

#motion compensated framerate converter; yv12 only
function mvfps(clip i, float fps, int "blur")
{
blur=default(blur,1)
fwd=mvtools0962_mvanalyse(i,isb=false,lambda=400)
bwd=mvtools0962_mvanalyse(i,isb=true, lambda=400)
i.mvtools0962_mvconvertfps(bwd,fwd,fps=fps*blur)
temporalsoften(round((blur)/3),255,255)
selectevery(blur,round(blur/2))
}

#revert PAL-DV to YV12 for quality reasons; needs yuy2 input (ie. canopus-dv-decoder)
function reYV12(clip i)
{
yx=i.converttoyv12().greyscale()
x=i.separatefields().separatefields().selectevery(4,0,2).weave()
ux=x.utoy().converttoyv12()
vx=x.vtoy().converttoyv12()
ytouv(ux,vx,yx)
}



function MVbob(clip c,int "blksize", int "pel", int "lambda", int "th", int "ths", int "bobth", bool "predenoise")
{
#find static parts (experimental)
function static_o_matic(clip i, clip j, int thy, int thc)
{
a=i.converttoyv12().motionmask(thy1=0,thy2=thy,thc1=0,thc2=thc,thSD=255,y=3,u=3,v=3)
logic(a,a.trim(1,0),"OR",y=3,u=3,v=3)
undot()
overlay (i,j, mask=last)
}

#disable all scene detection of mvcompensate(), because mvbob() is self-correcting due to the corrector()
sc=255

# threshold for correcting failed compensated motion
th=default(th,8)

# threshold for correcting static areas
ths=default(ths,3)

# deinterlacing threshold for the motion vector analysis do not go much higher than 10
bobth=default(bobth,8)

#denoise the video for the bobber (better static areas for noisy video, crappy)
predenoise=default(predenoise,false)

#defaults for the mocomp
blksize=default(blksize,8)
scd=(blksize==8)? 300 : round(300/4)
pel=default(pel,2)
lambda=default(lambda,1000)

#determine clip Fieldorder
order=(c.getparity==true)? 1:0
yv12 = isyv12(c)

# bobx -> kerneldeinterlaced video, used for motion search

# mvf -> motion vectors forward
# mvb -> motion vectors backward

# bobd -> blurred bobx for error checking (correcting false compensated blocks!)
# bobdf -> forward compensated bobd
# bobdb -> backward compensated bobd
# bobdm -> average of bobdb and bobdf

# fields-> ELA-deinterlaced fields for motion compensated output and compensation correction
# mcf -> forward compensated fields
# mcb -> backward compensated fields
# cv -> average of mcb and mcf

# dpf -> forward compensated fields (global motion)
# dpb -> backward compensated fields (global motion)
# dp -> average of dpb and dpf

# mc -> corrected motion compensated result

# create clip for motion analysis and hole-filling
bobt=predenoise ? c.temporalsoften(2,5,10) : c
bobc=bobt.leakkernelbob(order=order,threshold=bobth,twoway=true,sharp=true)
bobc= (order==1) ? bobc.assumetff() : bobc.assumebff()
bobx= yv12 ? bobc : bobc.converttoyv12()
bobd=bobx.undot().verticalreduceby2()
bobd=bobd.lanczos4resize(bobx.width,bobx.height).blur(0,1)


# create clip for motion compensation
fieldsx = c.tdeint(mode=1,mthreshl=bobth,mthreshc=bobth+2,type=3,Link=0)
fields= yv12 ? fieldsx : fieldsx.converttoyv12()


# create motion vectors
mvf=bobd.mvanalyse(blksize=blksize,pel=pel,isb=false,chroma=true)#,search=3,searchparam=10)
mvb=bobd.mvanalyse(blksize=blksize,pel=pel,isb=true, chroma=true)#,search=3,searchparam=10)

# create clips for mismatch detection
#local motion
bobdf=bobd.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
bobdb=bobd.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
bobdm=bobdf.mergeluma(bobdb,0.5).mergechroma(bobdb,0.5)

#global motion
# bobdpf=fields.MVDepan(mvf, zoom=true, rot=true, pixaspect=1.0 )
# bobdpb=fields.MVDepan(mvb, zoom=true, rot=true, pixaspect=1.0 )
# bobdpm=bobdpf.mergeluma(bobdpb,0.5).mergechroma(bobdpb,0.5)

# create the motion compensated clip that are passe to the output
#local motion
mcf=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc).deblock()
mcb=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc).deblock()
cv=mcf.mergechroma(mcb,0.5).mergeluma(mcb,0.5)

#global motion
# dpf=fields.MVDepan(vectors=mvf, zoom=false, rot=false, pixaspect=1.0,thscd1=scd,thSCD2=sc,info=false,error=255 )
# dpb=fields.MVDepan(vectors=mvb, zoom=true, rot=true, pixaspect=1.0,thscd1=scd,thSCD2=sc, info=false,error=255 )
# dp=dpf.mergechroma(dpb,0.5).mergeluma(dpb,0.5)


# detect mismatches of mvtools and replace them with motion adaptive bobbed areas
mc=corrector(bobd,fields, bobdf,bobdb, mcf,mcb, mode=0,th=th)
#mc=corrector(bobd,fields, bobdpf,bobdpb,bobdf,bobdb, dpf,dpb,mcf,mcb, mode=0,th=th)

# merge corrected output and raw output into one frame horizontally
mc=stackhorizontal(mc,cv)

# select the correct lines
compensated_even=(order==0) ? mc.selecteven().separatefields().selectodd() : mc.selecteven().separatefields().selectodd()
compensated_odd =(order==0) ? mc.selectodd() .separatefields().selecteven() : mc.selectodd() .separatefields().selecteven()

# ensure correct chroma format
compensated_even=yv12 ? compensated_even : compensated_even.converttoyuy2()
compensated_odd =yv12 ? compensated_odd : compensated_odd .converttoyuy2()

# merge them with the original fields
original_even=c.separatefields().selecteven()#.lev(0)
original_odd =c.separatefields().selectodd()#.lev(0)

even=interleave(stackhorizontal(original_even, original_even), compensated_even).weave()
odd =interleave(stackhorizontal(original_odd , original_odd ), compensated_odd ).weave()

interleave(even,odd)

#separate into corrected and raw video || correct static areas
mc_corr=crop(last,0,0,width/2,0)
mc_raw =crop(last,width/2,0,0,0)
static_o_matic(mc_raw,mc_corr,ths,ths)

# some lines for developement, visualisation and comparision.... uncomment if wished...
# stackhorizontal(last,fieldsx) #show mvdeinterlaced and t-deinterlaced video side by side for comparsion
# interleave(last,fieldsx) #alternate mv- and t-deinterlaced video

}


loadplugin("C:\avisynth\mvbob\Tdeint.dll")
loadplugin("C:\avisynth\mvbob\LeakKernelDeint.dll")
loadplugin("C:\avisynth\mvbob\Masktools.dll")
loadplugin("C:\avisynth\mvbob\MVtools0962.dll")
loadplugin("C:\avisynth\mvbob\MVtools0991.dll")
loadplugin("C:\avisynth\mvbob\Undot.dll")




with this

setmemorymax(256)
loadplugin("C:\avisynth\toms\tomsmocomp.dll")



import("C:\avisynth\reinterpolate420.avs")
import("C:\avisynth\mvbob\mvbob.avs")

avisource("C:\avisynth\noisepng.avi")

reinterpolate420() # if you are using DV.
mvbob()
selecteven()

This script will:
1)Deinterlace using mvbob.
2)and convert PALDV to 25progressive.
yes?

Also I am a bit confused... This script uses 3 deinterlacers (tdeint, tomsmocomp in reinterpolate script, and the mvbob). Isn't this unnecessary?

Also I have read something on another thread... Reinterpolate420 should not be used if you are going to convert your dv to dvd? or did you mean that reinterpolate420 should not be used directly for dv to dvd?

Thanks and I am very sorry for any inconvenience that I have caused.

freezer
2nd September 2005, 10:33
@ scharfis_brain
thank you very much for your help.

I am sorry, but at the moment I have no possibilities to post sample images, hope I can provide them later.

I understand now how the motion blur works and I am totally satisfied with the results. I work out the follwing script:

assumeBFF()
reinterpolate420()
mvbob()
SelectEven()
pixiedust()
ConvertToYV12(interlaced=false)

# SMOOTHING THE REMAINING EDGES
# Upsize the Source ...
Lanczos4Resize(720, 1152)
# Grab off-setting pixels(?) ...
top = SangNom(order = 0)
btm = SangNom(order = 1)
# Overlay the offset images on top of each other ...
top.overlay(btm, opacity = 0.5)
# Resize back down to native resolution ...
Lanczos4Resize(720, 576)

LimitedSharpen(ss_x=2.2, ss_y=2.2, Smode=1, strength=300)
ConvertToYUY2(interlaced=false)

But now I came to a strange problem.
I deinterlaced a clip, where there is a white text insert (without any motion) on black for several seconds. After using the above script, the text insert lasts only 1 frame, but it should be 150 frames.
That is very weird! I checked the clips - they are absolutely identical until the text insert, after that the clip continues, but the last 149 frames are black (which is equivalent to the missing text insert frames).
Both clips have the same amount of frames.

Does anyone have an idea why this is happening and how I can prevent this?

EDIT:
It seems like mvbob() does make this. But why? Is this a bug?

freezer
12th September 2005, 09:23
@ Scharfis_brain
No ideas why this happens? Does mvbob() just throw away frames when they are static?

scharfis_brain
12th September 2005, 13:06
hmm. I have no idea.

can you provide a sample clip and the fitting minimal script, which produces this error?
tell me about your AVS version, too.

Didée
12th September 2005, 13:19
Could simply be caused by the processing chain being too complex.

Or:

How was that "text insert" created & put into the clip? Just in case the creation of the text part includes PixieDust(), too, then the 2nd call of it (after SelectEven() in your above script) will not work, since PixieDust allows only one instance of itself to process any frame.

freezer
12th September 2005, 18:20
The complete video was cut in PremierePro and exported as DV AVI.
The text insert itself was just a static frame with the text and a duration of about 6 seconds, no fade in or out.

It happens even if there is mvbob() as the only command.

Wait a sec: what if it has been exported with the option to optimize still frames? That would mean that there is a single frame with the setting to hold it for 6seconds...
I have to check this.

freezer
13th September 2005, 17:45
OK, I checked it and it really was the option "Optimize Stills".
So everything should be ok now.

Thanks Scharfi & Didée for your help. Especially without Didées filter chains I would not be able to pull the quality to the max!

WorBry
8th November 2005, 23:04
Hi Scharfis-Brain,

I know this has come up in various threads, relating either to bob-deinterlacers or the "film effect", but could you please put me out of my misery regarding the options available for converting 50fps to 25fps.

I am of course using the very excellent MVBob for bob-deinterlacing my PAL-DV sources to 50fps producing superbly fluid motion. However, simply using "SelectEven" to convert back produces too much flicker for my liking. So I've tried all of the blending options (overlay, merge chroma/luma, BlendBob etc) that people have suggested, and again am not that satisfied with the results - too much ghosting for my taste.

I thought the commercial framerate converter MotionPerfect might be the answer. However, GooderVideo confirmed to me that for 50fps to 25fps conversion the output will be entirely composed of original frames that fall on target, which, unless I'm mistaken, is just the same as SelectEven

Posts in various threads have pointed to mvfps as a superior method for 30i to 24p and other tricky conversions. My inevitable question then is, is there any particular advantage in using mvfps for 50p to 25p or is the end result always going to be selection of the even frames from the 50p source? If it does offer an advantage, what settings would you recommend and what version should I use, as I have come across two versions:

1.In http://forum.doom9.org/showthread.php?t=89601

function mvfps(clip i, float fps, int "oversample", int "blurradius")
{
oversample=default(oversample,1)
blurradius=default(blurradius,1)
j=i.temporalsoften(2,4,5,2)
fwd=mvtools0962_mvanalyse(j,isb=false,lambda=4000)
bwd=mvtools0962_mvanalyse(j,isb=true, lambda=4000)
i.mvtools0962_mvconvertfps(bwd,fwd,fps=fps*oversample)
(oversample>1) ? last.temporalsoften(blurradius,255,255,mode=2).selectevery(oversample,0) : last
}

2.In MVBob.avs

function mvfps(clip i, float fps, int "blur")
{
blur=default(blur,1)
fwd=mvtools0962_mvanalyse(i,isb=false,lambda=400)
bwd=mvtools0962_mvanalyse(i,isb=true, lambda=400)
i.mvtools0962_mvconvertfps(bwd,fwd,fps=fps*blur)
temporalsoften(round((blur)/3),255,255)
selectevery(blur,round(blur/2))
}

It crossed my mind that a way to reduce the ghosting associated with blending methods would be to first ramp up the framerate to say 100fps using mvfps and then merge the luma/chroma as follows:

Import("C:\...\mvfps.avsi")

a=avisource("C:\...\50fps.avi").ConvertToYV12().mvfps(100)
b=a.trim(1,0)
x=a.mergeluma(b,0.5).mergechroma(b,0.5).SelectEven()
c=a.trim(2,0)
d=a.trim(3,0)
y=c.mergeluma(d,0.5).mergechroma(d,0.5).SelectEven()
LAST=x.mergeluma(y,0.5).mergechroma(y,0.5).SelectEven()
FINAL=LAST
Return(FINAL)

It certainly looks better than a straight two-frame merge/blend. Does this seem a valid approach to you?

scharfis_brain
9th November 2005, 01:33
it is a solution indeed.

but the upper mvfps function does it by itself!

example: nearly endless short shutter time (1/1000 sec or so) PAL video and you want to achieve Film like motion blur (about 1/35 sec to 1/50 sec).
film like motion blur means: the film is exposured to light for half to 2/3rd the duration of the frame itself. leading to motionblur-tails half as long, as with full shutter.
full shutter: the motion blur tail are touching each others end from frame to frame.

xxxsource("blah.xxx")
assume?ff()
mvbob()
mvfps(25,oversample=8,blurradius=2)

oversample=8 will internally calculate 25*8=200 fps
blurradius will blend 2*2+1 = 5 images out of the 8 images together.


the higher the oversample, the better the quality (lesser ghosting on fast movements), but you also need to raise the blurradius, of course:

oversample=16 needs at least 8 frames of those 16 over-frames blurred together, which means, that a radius of 4 has to be choosen. (radius of 4: 4*2+1 = 9 frames)

oversample=32 needs at least 16 frames of those 32 over-frames blurred together, which means, that a radius of 8 has to be choosen. (radius of 8: 8*2+1 = 17 frames)

more than radius of 8 is not possible, due to temporalsoften limitations.

WorBry
9th November 2005, 02:21
Excellent. Thanks so much.

mg262
9th November 2005, 04:51
scharfis,

This is interesting... I had never thought about motion blur as an application for motion compensation. Can I ask about this:

more than radius of 8 is not possible, due to temporalsoften limitations.What limitations are these?

scharfis_brain
9th November 2005, 10:18
the limitation is - out of the users view - that it just doesn't blur more frames if raining radius over 8. It doesn't return an error.

Maybe I should rewrite it. But maybe you already know: I am lazy!

mg262
9th November 2005, 17:44
Mmmm... it would be fairly quick to write a TemporalAverage function that returned the average of all the frames within a given radius (either with equal weighting or with e.g. bell curve); it wouldn't try to detect scene changes, but for this application that shouldn't matter too much. Do you think that would be useful?

scharfis_brain
10th November 2005, 00:23
It would be more useful, if I could use a paramter that defines a number of frames instead of a radius.
Scene change detection would be a good addition though.

mg262
10th November 2005, 15:38
Number of frames would be easy. Suppose number of frames = 4; which frames would be averaged to give output frame 10? Input frames 9, 10, 11, 12?

Scene change detection is not hard to implement... but:

Because I nearly always work with animated material, I'm not confident about scene detection on live-action
I need it in many filters


So at some point, I will probably release a filter whose purpose is scene detection; it will output a clip that can be fed to this filter, my stabiliser stuff, motion compensation, maybe blend reversal, and anywhere else I might want it. Then I can update the scene detection (e.g. to work better with live-action) without having to rerelease lots of filters.

mg262
15th November 2005, 01:59
The revised BlendFPS function that I released here:

http://forum.doom9.org/showthread.php?p=737873#post737873

does everything that TemporalAverage would have and more. If you want to simulate a temporal average, use it with the target frame rate equal to the starting frame rate and aperture equal to the number of frames you want averaged.