PDA

View Full Version : Anti-Flicker Filter


zyrill
12th December 2002, 13:27
Hi everyone!

Since i am encountering an extremely fluctuating brightness in a film i need to encode i have asked myself if there was any avisynth-filter dealing with this problem. since i found none i'm presuming there are none.
Now, i have thought about coding an own one but since my knowledge of programming is rather inferior (only php, delphi and stuff like that), i came to ask for someone to either write one or help me create one. As i do not have the slightest idea of what an algorithm to compare the brightness of frames (and to correct it) could look like i'd really like somebody to fill this gap. Every possibility i tried so far would raise/decrease the brightness when i don't want it to be changed. any great ideas on how to code this?

Bidoche
12th December 2002, 13:32
There is an anti-flicker filter for virtualdub made by donald graft.
You can have it on his web site : http://shelob.mordor.net/dgraft/

neuron2
12th December 2002, 13:33
There is an anti-flicker filter and source code for VirtualDub at my web site (see below). Look under the section called 'Mine'. It works well but really needs to reset at scene changes. That wouldn't be hard to add.

If you converted this to an Avisynth filter, you would not need to use two passes over the source as the VirtualDub version does.

zyrill
12th December 2002, 14:54
well basically i want a filter that works within yuv color space (i don't won't to convert to rgb) - does anything like that exist already?

why wouldn't i need two pass when porting it to avisynth?

neuron2
12th December 2002, 15:17
Originally posted by zyrill
well basically i want a filter that works within yuv color space (i don't won't to convert to rgb) - does anything like that exist already?Not that I know of.

why wouldn't i need two pass when porting it to avisynth? Avisynth filters are capable of random frame access.

zyrill
12th December 2002, 18:45
:confused: i'll be back in about 10 years... when i finally understand your deflicker 1.1 code! ARGH! :(

i think i need a mentor with lot's of time for understanding that code - where can i find info on what e.g. src (well i figured that one out, but still - there are a whole lot more of those stupid objects i don't know), dst, pfsi are? and wtf is the kernel used in this file? i think i'll go to university first, come back when i've got my title and then i'll have another look... or do you think it's any help when i try to fumble around with it? i mean i'm not stupid but i'm still in school and i only know the very basics about winapi and delphi... never had a look at c++.

neuron2
12th December 2002, 19:07
Originally posted by zyrill
:confused: i'll be back in about 10 years... when i finally understand your deflicker 1.1 code! ARGH! :(

i think i need a mentor with lot's of time for understanding that code - where can i find info on what e.g. src (well i figured that one out, but still - there are a whole lot more of those stupid objects i don't know), dst, pfsi are? and wtf is the kernel used in this file? i think i'll go to university first, come back when i've got my title and then i'll have another look... or do you think it's any help when i try to fumble around with it? i mean i'm not stupid but i'm still in school and i only know the very basics about winapi and delphi... never had a look at c++. Tell you what... I'll convert it into an Avisynth filter for you. Give me a week or so as I am quite busy these days.

Marc FD
12th December 2002, 20:20
and just after i load the sources and i low-level optimise them... LOL ^^

@zyrill

i think i'm not much older than you ^^
you know, C/C++ is really easy to code, you just take some time to get used. i started avisynth filters and C/C++ devellopement by converting a VDub filter in Avisynth.... and it really taked a lot of time ^__^ (i finally realised than rewriting it was easier !)

if you have the right tools and the will, read a lot open-source code, that's how you learn the most things.

Cheers,
MarcFD

zyrill
13th December 2002, 15:16
Thanks a million, Donald! i can't rival your filters anyway so it's probably a lot better when you do it, anyway.

marc: nice trick, isn't it? :rolleyes: but i really are very confused by the code. there are so many code-snippets i don't know i can't even figure out the system with which the filter works. and gee, right then i realized that i was too bad for it! but maybe you can help me learn some stuff so i get a clue from where to start. may i contact you when i encounter any difficulties while learning?

Marc FD
13th December 2002, 17:40
zyrill, there's a devellopement on doom9 and UV, if you have really a problem understanding someting, you'ld find help there ^^

neuron2
13th December 2002, 20:45
OK, I made a quick-and-dirty port of the VirtualDb filter (which sucks, by the way; it was one of my first filters). Use the flick1.avi from the VirtualDub test files as the test file. Then try this script:

loadplugin("..\release\antiflicker.dll")
avisource("flick1.avi")
crop(16,16,-16,-32)
swapuv()
converttoyuy2()
antiflicker()
temporalsoften(3,20,20)

Notes:

1. Omit swapuv() if not required.
2. Antiflicker will take the window size as a named parameter [window=25 is default, range 2-200].
3. Timeline random access NOT supported. So start from frame 0 and play straight through.
4. The temporalsoften() replaces the built-in DNR in the VirtualDub version. Antiflicker() equalizes the frames globally, and TemporalSoften() adds final per-pixel equalization. Both are necessary for acceptable results.

Don't ask for much more. I don't find this very exciting. :p

WarpEnterprises
13th December 2002, 23:18
another way to get 2.5 spread ;)

Btw found a really good and short C++ tutorial

http://www.cplusplus.com/doc/tutorial/

I'm also trying to compile/modify/... AviSynth filters but without some tight C++ background before you won't be able to do much.

neuron2
13th December 2002, 23:27
Originally posted by WarpEnterprises
another way to get 2.5 spread ;)
How so? Antiflicker supports only YUY2.

WarpEnterprises
13th December 2002, 23:31
ohh, thought SwapUV is 2.5.

FredThompson
14th December 2002, 05:34
I've just started testing this with some NTSC DV I shot in Europe earlier this year.

The room had huge windows so there was a lot of natural sunshine but the ceiling lights were running on 50 hz. The result is an image background which flickers while the subject is usually just fine.

The "cleaned up" version isn't perfect but it IS nicer.

neuron2
14th December 2002, 05:36
Can I get an input clip for my torture suite, please?

Let's see... 60Hz-50Hz gives a 10Hz flicker.

What window size did you use?

You can put multiple calls to Antiflicker, you know. :)

neuron2
14th December 2002, 05:42
Originally posted by WarpEnterprises
ohh, thought SwapUV is 2.5. It is. :)

FredThompson
14th December 2002, 05:56
Originally posted by neuron2
Can I get an input clip for my torture suite, please?

Let's see... 60Hz-50Hz gives a 10Hz flicker.

What window size did you use?

You can put multiple calls to Antiflicker, you know. :)

Yeah, sure. I can grab some stuff for you. Gonna be big, though, it's DV. How many frames will you want?

The difference won't always be 10 Hz. That would only be for one cycle if they start at the same time, won't it? Maybe I don't understand what you're saying.

Don't remember the settings, I played around with the VirtualDub version last night. Give me a day to reproduce the results. Running some long jobs on that computer right now. Can't import DV until they're done.

Geez, I paid over USD$1K last year to have some old film converted. Hindsight...20/20...would have bought a projection hood and a very nice dual CPU mobo set up...

Wonder how this process would work on NTSC shots of a PAL TV. I'll take some next time I'm over there so it can be tested.

neuron2
14th December 2002, 06:11
>Yeah, sure. I can grab some stuff for you. Gonna be big, though,
>it's DV. How many frames will you want?

Transcode to DivX or Xvid. :)

>The difference won't always be 10 Hz. That would only be for one
>cycle if they start at the same time, won't it? Maybe I don't
>understand what you're saying.

It's all about beat frequencies.

FredThompson
14th December 2002, 06:40
Oh, I thought it was all about the Benjamins ;)

neuron2
14th December 2002, 15:10
Originally posted by FredThompson
Oh, I thought it was all about the Benjamins ;) Valarie Rae Miller -- the original 'Dark Angel'.

esby
4th March 2003, 17:14
Is this filter is avs 2.0X or 2.5 actually ?
Tried to open it with avs 2.5,
it saying that it is not an avs 2.5 plugin...
But
swapUV() is 2.5
www.avisynth.org refers to it as a 2.5 plugin... and links to this thread...
So...
Am i missing something?

esby

WarpEnterprises
4th March 2003, 17:29
It is for 2.5 but only YUY2 and with the old pluginiInit.
a hex-edited (plugininit2) version that should work:

http://www.avisynth.org/FileHosting/users/WarpEnterprises/files/Antiflicker.zip

Wilbert
4th March 2003, 17:35
Thx for pointing this out. I will add a link to the faq.