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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st June 2003, 10:27   #1  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
QMF & FMF v1.5 b1 (page 3)

Hi all,

I've played a little (maybe more than that in fact) with the "new" built-in conditional functions inside Avisynth 2.5.1 and later. This script is one of the four different scripts that I made which use these conditional functions: the purpose is very simple, but it proved its strength on the different test clips that I gave it.

What does it do?
It splits the provided video clip into 3 motion levels: low motion, medium motion and high motion, using a (very) simple motion estimation algorithm. Then, it applies different user-defined filters for each motion level, allowing you to do some adaptive smoothing/sharpening (or anything else you want).

Features:
+ adaptive filtering according to motion
+ 3 motions levels (low, medium and high) for 3 different user-defined filters
+ built-in scene change detection algorithm for better motion estimation
+ use of chroma channels for better motion estimation (optional)
+ many user-defined parameters for tweaking
+ detailed debug information display for better tweaking experience (optional)
- YV12 input only! (use ConvertToYV12() when needed)
- Avisynth 2.5.2 or later recommended!

How can I use it?
You just need to define 3 user-defined at the beginning of the script, called Low_Motion_Filter, Medium_Motion_Filter and High_Motion_Filter, which you put your selected filters for each motion level in. Look at the examples provided with the release if needed.

What's this debug thing?
I have a few things to add about debug=true (a parameter which displays debug information over the video clip). When using debug=true, you should always look at the video clip (for instance inside VirtualDubMod) sequentially and in the right order (from past to future). Why? Because my scene change detection doesn't work on a 1-frame basis, but on a 5-frame basis. I won't go into the details here but if you want any information I'll be happy to answer.

What's next?
I've coded 3 other scripts which use the conditional functions:
- Continuous Motion Filter: this script is an adaptive motion filter, but with only one motion level. Inside this motion level, limited by min and max threshold values (user defined parameters), the parameters used inside the filters are scaled linearly on each frame between min and max values (user-defined parameters).
- Full Motion Filter: this script is the "son" of QMF and CMF. It uses 3 motion levels (like QMF), and inside these 3 motion levels the parameters used inside the filters are scaled linearly on each frame (like CMF).
- Scene Change Cleaner: this script is only designed for bad PAL anime sources, and its purpose is to clean the bad blended scene changes that occur all the time. It works quite good.
If someone wants to see one of these filters, feel free to ask for it.

Quantified Motion Filter v1.3 (21/06/2003)

I'd be happy to have some feedback if anyone is interested. Thanks in advance.

HomiE FR

Last edited by HomiE FR; 10th July 2003 at 20:48.
HomiE FR is offline   Reply With Quote
Old 21st June 2003, 10:40   #2  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
Hi HomiE
In your readme you've copyrighted your script and said not to steal it.

Most of us here release under the GPL (or completely non-copyright)and let people modify our efforts so that the whole community can benefit.

Maybe you'd consider changing your conditions ?

regards
Simon
Si is offline   Reply With Quote
Old 21st June 2003, 11:46   #3  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
When I say steal I don't mind if people do some copy/paste (really) I just would like a word of credits if possible.
I'm no pro in the domain, but everyone can modify it (I don't know if the credits part is too much...). I wouldn't like to be seen as a guy who wants to copyright things which are so simple (and even if I wanted it, which is not the case, I wouldn't be able so)

Thanks for pointing this out, of course everyone can play with the script (which is well commented I think).

Edit : I've corrected the readme file. The "new" version is online.

Last edited by HomiE FR; 21st June 2003 at 12:41.
HomiE FR is offline   Reply With Quote
Old 21st June 2003, 23:43   #4  |  Link
iago
retired
 
iago's Avatar
 
Join Date: Jun 2002
Location: hollywood
Posts: 1,013
Very useful! Thanks a lot!

I've been playing with it for some time now and trying to configure it to exactly suit my taste .

(For high motion -> UnFilter(-100,-100) for instance! )

Last edited by iago; 21st June 2003 at 23:47.
iago is offline   Reply With Quote
Old 21st June 2003, 23:55   #5  |  Link
avih
Capture, Deinterlace
 
avih's Avatar
 
Join Date: Feb 2002
Location: Right there
Posts: 1,971
that's a very good idea, however, i wonder how does it handle the transitions (didn't try your script yet). switching filters bay result in harsh quality differences. how about merging the transitions within about 5-10 frames using variable alpha transpatencies? (is that possible at all?)

cheers for the script.
avih is offline   Reply With Quote
Old 22nd June 2003, 02:39   #6  |  Link
bilu
Registered User
 
bilu's Avatar
 
Join Date: Oct 2002
Location: Portugal
Posts: 1,182
Imagine you do a Telecide or Uncomb over a telecined movie. You would get duplicates every five frames, even in high-motion scenes.
I presume this would be treated as low-motion...

Would it be possible for you to add a "scene protect threshold", i.e. that would treat the movie like high-motion until a defined number of low-motion scenes passes through?

This is what I have in mind:
http://forum.doom9.org/showthread.ph...822#post332822


Thanks in advance,
Bilu
bilu is offline   Reply With Quote
Old 22nd June 2003, 06:05   #7  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
First of all, thanks for the replies/feedback!

iago : I hope the whole debug thing is helping you in tweaking the script.

avih : This idea about transparencies seems really interesting. But there is another way to handle it I think (at least in some way) : I coded another script which is called CMF and which is quickly described in the first post. It uses only one motion level and adjusts parameters that you set (min/max value for min/max difference between frames) linearly. This way there is no transition anymore.

But this supposes that you use the same filters for the whole motion range, that's why your idea about transparency should be great in every other case (like this script). I'll look into that! Thanks.

bilu : Duplicates are not a real problem, because this script uses differences from past and future to compute its average difference/motion level (2 frames in the past and 2 frames in the future max). You can play with temporal_influence (from 0 to 100) to adjust the past and future frames difference ratios. But I could do what you want I think, I'll have a look at it.
(I'll check your topic about automatic decombing too. )
HomiE FR is offline   Reply With Quote
Old 22nd June 2003, 23:11   #8  |  Link
iago
retired
 
iago's Avatar
 
Join Date: Jun 2002
Location: hollywood
Posts: 1,013
Quote:
Originally posted by HomiE FR
iago : I hope the whole debug thing is helping you in tweaking the script.
Sure it is. And imho the three motion levels are pretty well configured. Also, though I agree with avih that sharp transitions between filters and/or aggressive parameters may cause certain problems, in my first full encode with the script using my own tweaked filters/settings I haven't encountered such a problem (yet ).

Good work! Thanks again!

Last edited by iago; 22nd June 2003 at 23:19.
iago is offline   Reply With Quote
Old 23rd June 2003, 07:22   #9  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
iago : I haven't seen these sharp transition problems yet either. But I'm trying to figure out how to do it better, although the problem is that transparencies need RGB32 (and the conditional functions need YV12). So it is not a real problem but it implies some color space conversions inside the script, which is not particularly good.
But I'll try to do something so that we can decide whether it is worth the conversions or not.

Thanks for using the script too.
HomiE FR is offline   Reply With Quote
Old 23rd June 2003, 09:52   #10  |  Link
yaz
n00b ever
 
Join Date: May 2002
Posts: 627
@HomiE FR
xxllent work!!! as my system is not fully sse compliant, i had to find sg of that kind. i did & it did worth to do so! man, it's damn good! (anyway, u should mention this compliancy issue in the readme)

some clues:
in this form, it's a thresholded filter. as the debug part is also very good it's not too hard to tweak. anyway, have u ever thought of adaptive thresholding? i mean, deriving the actual threshold from the previous difference(s). such algos were extensively used in the divx3 times & they work(ed) pretty good. imho, the best one is implemented in nandub. if anybody were interested, we'd go into details.
as an improvement; filter strength would be (should be?) derived directly from the motion output. say, higher motion -> lower temp & higher spat filter strength. or doing blurring/sharpening according to motion. i.e. sharpen, unfilter, asharp can be tuned very easily.

@iago
happy to see ya again!
... transition problems wont arise as long as motion thresholds are correct. i see crossfades more problematic. i haven't been able to tune these scenes correctly. even not with this cute filter.
... be careful with unfilter (& with other blur/sharpen tricks) i've just realized that ur earlier intentions were true (in that monstruos thread, d'ya remember? :-) they modify the yuv values, sometimes very heavily, & if so they can produce very strange effects. just a quick reflection to unfilter(-100,-100).

the bests
y
yaz is offline   Reply With Quote
Old 23rd June 2003, 12:12   #11  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
yaz : I didn't know there was a problem with SSE compliance. Thanks for pointing this out.

About adaptive thresholding and filter strength directly derived from motion, I already did a script which does (at least in some way) that : Continuous Motion Filter (I can give you a working version if you want).

In that filter, there is only one motion filter function, in which you put lines such as :
Code:
c = FluxSmooth(c,param1,param2)
Then when you call CMF (the main function), you use some parameters to define the min and max values of the parameters you used in the motion filter function. For instance, param1_min=0, param1_max=14. You also define min and max motion levels the same way, and scene change thresholds the same way too.

Then the parameters and the sc threshold are scaled linearly between their min and max values according to current motion. So I guess it's a sort of adaptive thresholding. I could also do something where (only for sc threshold) the user doesn't have to enter any min and max value but I believe people like to tweak things to their bests.

But if you have an idea on how to improve it, feel free to share your knowledge!

HomiE FR
HomiE FR is offline   Reply With Quote
Old 23rd June 2003, 13:31   #12  |  Link
iago
retired
 
iago's Avatar
 
Join Date: Jun 2002
Location: hollywood
Posts: 1,013
Hello yaz,

Yeah, it's nice to meet you again. And, sure, how can I forget that monster thread! :-)

UnFilter(-100,-100) was kinda kidding and not serious actually, but I used UnFilter(-60,-60) together with FluxSmooth(0,14) for high motion in my Blues Brothers encode, which 'surprisingly' gave me no visible artifacts or quality decrease due to filter/parameter transitions.

Also, I replaced FluxSmooth with TemporalCleaner(5,10) and TemporalCleaner(3,6) for low and middle motion together with UnFilter(-5,-5) and UnFilter(-20,-20) respectively, which would theoretically really 'invite' some artifacts especially when switching to hi-mo .

However, the result (and the compression gain due to heavy filtering of loads of high motion scenes that definitely resulted in the increase of the overall quality) was really good for that particular hard-to-compress movie with 640*336 bicubic resolution keeping the ac3 track.

Anyway, let's try the script with some tweaking on a couple of more sources now!

ciao,
iago

Last edited by iago; 23rd June 2003 at 13:34.
iago is offline   Reply With Quote
Old 23rd June 2003, 16:08   #13  |  Link
yaz
n00b ever
 
Join Date: May 2002
Posts: 627
Quote:
Originally posted by HomiE FR
I didn't know there was a problem with SSE compliance.
yep. most of the script functions need full sse compliance. (it's time to build a new system :-)

Quote:
Originally posted by HomiE FR
... Continuous Motion Filter ...
i saw that description but it's not xactly what i meant. that good old scene change detectors i mentioned worked like this :
next_threshold = factor * current_threshold
they were pretty good in detecting scene changes &(!) crossfades. but (just to disagree with myself:-) it's less useful detecting motion as done by ur filter. in add, finding a good factor in yv12 would need some time. but (maybe) it'd worth. just a clue.

anyway, i'd be interested in ur other filters very much. scaling filter strength according to motion/changes (as u described) is a very promising field.

Quote:
Originally posted by HomiE FR
But if you have an idea on how to improve it, feel free to share your knowledge!
sure, ya kiddin :-) it's just good as it is.
but why not ? what about joining your motion detector with my scene change detector (idea). imho, scene changes need different handling than high motion scenes & than crossfades (especiallly the slow ones) while any of that can generate similar motion values with your detector.

@iago:
what a settings:-) a brave user u r:-)
(offtopic) have u ever noticed that fluxsmooth are willing to make strange color spotting? say, just try fluxsmooth(x,128), or so. i thought that with such high threshold it should do something similar to undot, but instead it made heavy color dots here & there. it wasn't a thorough test (as i dropped it immediatly:-) but since then i'm very careful with its spatial part.
using unfilter for heavy blurring ... hmm ... should try anyway

the bests
y
yaz is offline   Reply With Quote
Old 25th June 2003, 04:44   #14  |  Link
Dali Lama
Registered User
 
Join Date: Jan 2002
Posts: 331
Hi Homie FR,

I just wanted to point out that I think 0 in fluxsmooth still performs spatial/temoral smoothing. One must use -1 to disable spatial/temporal smoothing.

Also, nice script!

Oh and I'd like to share my opinion that using conditional filtering is nice, but it doesn't mean one should forget about setting "proper" thresholds and not going to extremes...I am not going to mention names...Iago...just joking.

Take Care guys,

Dali
Dali Lama is offline   Reply With Quote
Old 25th June 2003, 14:13   #15  |  Link
iago
retired
 
iago's Avatar
 
Join Date: Jun 2002
Location: hollywood
Posts: 1,013
Hello Dali,

Experimenting with extremes and gradually reducing strength is a good method to find the acceptable maximums for most filters .

iago

edit: as for fluxsmooth, yeah you're right, according to documentation by SansGrip one must use -1 (not 0) to cancel either temporal or spatial smoothing.

Last edited by iago; 25th June 2003 at 14:15.
iago is offline   Reply With Quote
Old 25th June 2003, 15:05   #16  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
yaz : Thanks! Your way of scaling scene change threshold could be ok, but the factor can't be constant IMHO. If I understood it right, we have threshold_sc = factor*motion (I'm not sure, maybe you meant new threshold_sc = factor*old threshold_sc). In both cases the factor must change according to motion. Maybe I'm missing something, anyway thanks.

Dali Lama : Thanks for the tip! I'll change it in the next release.

I think I will release soon the other scripts I wrote with the same goal in mind. I discribed them in the first post, theoretically they are more "powerful" than this one, but I must warn you: if there is only a memory leak in the filter you use with one of the 2 other filters, be ready to abort the encoding process, because your physical/virtual memory will be eaten quite fast!
This is because ScriptClip (the conditional function used inside) calls the filter used for each new frame: so if the filter doesn't free all the memory it took for the frame process, you can imagine that even a "small" leak can become huge with more than 50000 frames!
But if you want to give them a try, I'll be happy to post them!

HomiE FR
HomiE FR is offline   Reply With Quote
Old 26th June 2003, 21:42   #17  |  Link
Seiby
Registered User
 
Join Date: Mar 2003
Posts: 9
Hi,

thx for your filter, great work but...

The scene change detection doesn't work very well for me. For me less then 1/3 of all scene changes were found. Is there a way to tweak the scene change detection?

Sample: Scene Change, Medium Motion was detected, no scene change...
Sample

Anyway, great work to save bits in high motion scenes and keep details in slow motion scenes
Seiby is offline   Reply With Quote
Old 27th June 2003, 00:25   #18  |  Link
bilu
Registered User
 
bilu's Avatar
 
Join Date: Oct 2002
Location: Portugal
Posts: 1,182
Welcome to the forum Seiby


The answer lies in your own sample.

diff is less than threshold_sc, you would have to lower the threshold.



Bilu
bilu is offline   Reply With Quote
Old 27th June 2003, 05:38   #19  |  Link
HomiE FR
Registered User
 
Join Date: Jul 2002
Location: France
Posts: 140
bilu : Thanks for doing the feedback!

Seiby : Thanks for trying my script. I hope you'll be able to find good values without much problems (usually it should be the case).

yaz is totally right when he says that an adaptive thresholding could be great, but this wouldn't work well on anime where there are always (not during travellings) some duplicate frames where motion is very close to zero. So the factor wouldn't work.
But I could do some "anime=true" where the old thresholds are accessible (or maybe "thresholds=true") and with "thresholds=false" there is the yaz adaptive thresholding (© ) which should work perfectly with normal movie (not anime).

I'll release the other scripts I did on saturday (tomorrow). If you understood how this one worked there won't be any problem with the others (same debug thing, etc...)
HomiE FR is offline   Reply With Quote
Old 27th June 2003, 13:38   #20  |  Link
kilg0r3
! - User - !
 
kilg0r3's Avatar
 
Join Date: Nov 2001
Posts: 1,081
@ iago, HomiE, ...

In know this is kind of a stupid question but are you able to quanitfy your results? Some rough estimation like saved KB at same perceived quality would be great.
__________________
Keep your tone warm and your sigs decent!
kilg0r3 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Jump


All times are GMT +1. The time now is 12:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.