Filter for smoothening gradual luminance changes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Filter for smoothening gradual luminance changes?

Markku Tavasti
Hi!

I have tried to find out proper way to smoothen luminance changes on
videos of sunset. Cameras are action cameras where it is not possible to
set manually exposure etc, and in fact, it is not desirable. Typically
my video recordings are few hours, from full daylight, sun shingin
towards camera, and endig to darkness. So exposure changes gradually,
but problem is that on such cameras, change is annoying clear, sudden
change. Therefore, I'd like to smoothen that so that it is not that sudden.

See example what I mean https://youtu.be/vOVYZAcWpZE?t=23s

Video is shot as normal video, and then speeded up with ffmpeg. If video
would be done from pictures, then it is possible to change luminance of
each picture to match to average of surrounding pictures, but cameras I
use don't support taking pictures with given interval or provided
intervals are too long. Therefore making 'timelapse' from video is needed.

Any suggestions?

--Tavasti
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 16.04.2017 15:08, Markku Tavasti wrote:
> towards camera, and endig to darkness. So exposure changes gradually,
> but problem is that on such cameras, change is annoying clear, sudden
> change. Therefore, I'd like to smoothen that so that it is not that sudden.
>
> See example what I mean https://youtu.be/vOVYZAcWpZE?t=23s

Another example, where changes are not gradual, to one direction, and
video is speeded up more, so result is flickering:

https://www.youtube.com/watch?v=k1FY2HiPa2g

One option is to write all frames as pictures to disk, and then run
timelapse-deflicker.pl for them, and make video from those pictures.
However, that will take much time and disk space.

--Tavasti
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Moritz Barsnick
On Tue, Apr 18, 2017 at 10:45:24 +0300, Markku Tavasti wrote:
> One option is to write all frames as pictures to disk, and then run
> timelapse-deflicker.pl for them, and make video from those pictures.
> However, that will take much time and disk space.

Only after looking at that script[*] (and the lovely videos of course) do
I understand your intent: The brightness shall follow a rolling average
of sorts, i.e. be more or less monotonic (wrong term, I know).

I'm pretty sure that ffmpeg can't do that, as I know of no filter which
will create such an average and apply it. But a filter could be
written... I don't know if it would be a candidate for upstream though.

(I'd be willing to try, but my filter writing learning skills are stuck
at a different attempt. ;-))

[*] https://github.com/rambo/timelapse/blob/master/timelapse-deflicker.pl
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 18.04.2017 12:31, Moritz Barsnick wrote:
> On Tue, Apr 18, 2017 at 10:45:24 +0300, Markku Tavasti wrote:
>> One option is to write all frames as pictures to disk, and then run
>> timelapse-deflicker.pl for them, and make video from those pictures.
>> However, that will take much time and disk space.
>
> Only after looking at that script[*] (and the lovely videos of course) do
> I understand your intent: The brightness shall follow a rolling average
> of sorts, i.e. be more or less monotonic (wrong term, I know).

Yes, idea is that every frame would have brightness of average +-5
pictures surrounding it. timelapse-deflicker.pl reads luminance first,
and then it creates modified pictures based on those values. Seems to
work ok.

Maybe I try to create script which would get frames as pictures. And in
addition, to darkest parts of the video, there is huge noise in picture,
averaging maybe 4 frames migth give better results.

--Tavasti


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Paul B Mahol
In reply to this post by Moritz Barsnick
On 4/18/17, Moritz Barsnick <[hidden email]> wrote:

> On Tue, Apr 18, 2017 at 10:45:24 +0300, Markku Tavasti wrote:
>> One option is to write all frames as pictures to disk, and then run
>> timelapse-deflicker.pl for them, and make video from those pictures.
>> However, that will take much time and disk space.
>
> Only after looking at that script[*] (and the lovely videos of course) do
> I understand your intent: The brightness shall follow a rolling average
> of sorts, i.e. be more or less monotonic (wrong term, I know).
>
> I'm pretty sure that ffmpeg can't do that, as I know of no filter which
> will create such an average and apply it. But a filter could be
> written... I don't know if it would be a candidate for upstream though.

I just wrote deflicker filter.

>
> (I'd be willing to try, but my filter writing learning skills are stuck
> at a different attempt. ;-))

Which attempt?

>
> [*] https://github.com/rambo/timelapse/blob/master/timelapse-deflicker.pl
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
In reply to this post by Markku Tavasti
On 18.04.2017 14:02, Markku Tavasti wrote:
> Maybe I try to create script which would get frames as pictures. And in
> addition, to darkest parts of the video, there is huge noise in picture,
> averaging maybe 4 frames migth give better results.

Made a script:

----------------------------------------
#!/bin/bash

interval=1
if [ $# -gt 0 ] ; then interval=$1 ; fi
echo "Using interval of $interval seconds"

mkdir -p raw
mkdir -p avg
mkdir -p frm
FRM=0
for f in FHD*; do
   len=$(ffprobe  -select_streams v -show_streams $f 2>/dev/null| grep
'duration=' | sed 's/.*=//i;s/\..*//')
   echo $f $len $FRM
   pos=0
   while [ $pos -lt $len ]; do
     ffmpeg -ss $pos -i $f -frames:v 4 raw/frm$(printf "%05d"
${FRM})_%d.png 2>/dev/null
     convert raw/frm$(printf "%05d" ${FRM})_*.png -average
avg/frm$(printf "%05d" ${FRM}).png
     mv raw/frm$(printf "%05d" ${FRM})_1.png frm
     rm raw/frm$(printf "%05d" ${FRM})_*.png
     FRM=$(($FRM+1))
     pos=$((${pos}+${interval}))
   done
done

echo deflickering avg
cd avg
timelapse-deflicker.pl 2>/dev/null
echo deflickering frm
cd ../frm
timelapse-deflicker.pl 2>/dev/null
cd ..
ffmpeg -r 25 -pattern_type glob -i 'avg/Deflickered/*.png'  -c:v libx264
-pix_fmt yuv420p avg.mp4
ffmpeg -r 25 -pattern_type glob -i 'frm/Deflickered/*.png'  -c:v libx264
-pix_fmt yuv420p normal.mp4

----------------------------------------

And results https://youtu.be/5u3t6hiaEPI

Looks like ok. Uses lot of time and disk, real filter to ffmpeg would be
much faster, but I am not in such mass production / my release schedule
is not tight, so this will be sufficient to me.

--Tavasti
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
In reply to this post by Paul B Mahol
On 18.04.2017 20:06, Paul B Mahol wrote:
>> I'm pretty sure that ffmpeg can't do that, as I know of no filter which
>> will create such an average and apply it. But a filter could be
>> written... I don't know if it would be a candidate for upstream though.
>
> I just wrote deflicker filter.

Sounds great! Do you want some tester for it?

--Tavasti



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Paul B Mahol
On 4/18/17, Markku Tavasti <[hidden email]> wrote:
> On 18.04.2017 20:06, Paul B Mahol wrote:
>>> I'm pretty sure that ffmpeg can't do that, as I know of no filter which
>>> will create such an average and apply it. But a filter could be
>>> written... I don't know if it would be a candidate for upstream though.
>>
>> I just wrote deflicker filter.
>
> Sounds great! Do you want some tester for it?

Yes, Do you know how to apply patches and build master ffmpeg git?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 18.04.2017 22:35, Paul B Mahol wrote:
> On 4/18/17, Markku Tavasti <[hidden email]> wrote:
>> On 18.04.2017 20:06, Paul B Mahol wrote:
>>> I just wrote deflicker filter.
>>
>> Sounds great! Do you want some tester for it?
>
> Yes, Do you know how to apply patches and build master ffmpeg git?

Haven't build ffmpeg, but if it is decently buildable software in ubuntu
16.04, that won't be a problem.

--Tavasti
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Paul B Mahol
On 4/18/17, Markku Tavasti <[hidden email]> wrote:

> On 18.04.2017 22:35, Paul B Mahol wrote:
>> On 4/18/17, Markku Tavasti <[hidden email]> wrote:
>>> On 18.04.2017 20:06, Paul B Mahol wrote:
>>>> I just wrote deflicker filter.
>>>
>>> Sounds great! Do you want some tester for it?
>>
>> Yes, Do you know how to apply patches and build master ffmpeg git?
>
> Haven't build ffmpeg, but if it is decently buildable software in ubuntu
> 16.04, that won't be a problem.

Alternatively you could provide me link to original fotage.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 18.04.2017 23:02, Paul B Mahol wrote:
> Alternatively you could provide me link to original fotage.

I'll select relevant parts and put them to somewhere at the evening. The
whole original set is 15G (video was speeded 300x).

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 19.04.2017 07:04, Markku Tavasti wrote:

> On 18.04.2017 23:02, Paul B Mahol wrote:
>> Alternatively you could provide me link to original fotage.
>
> I'll select relevant parts and put them to somewhere at the evening. The
> whole original set is 15G (video was speeded 300x).
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

 From http://scl1.tavasti.fi/~tavasti/ you can find 3 video clips for
testing. Create video from them like:

ffmpeg -f concat -safe 0 -i <(for i in FHD*MOV; do echo file $(pwd)/$i;
done)  -an -filter:v "setpts=0.003*PTS" x333.mp4

And there you have the flickering. Sure, amount of test material might
be bit overscaled :-)
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Paul B Mahol
On 4/19/17, Markku Tavasti <[hidden email]> wrote:

> On 19.04.2017 07:04, Markku Tavasti wrote:
>> On 18.04.2017 23:02, Paul B Mahol wrote:
>>> Alternatively you could provide me link to original fotage.
>>
>> I'll select relevant parts and put them to somewhere at the evening. The
>> whole original set is 15G (video was speeded 300x).
>>
>> _______________________________________________
>> ffmpeg-user mailing list
>> [hidden email]
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> [hidden email] with subject "unsubscribe".
>
>  From http://scl1.tavasti.fi/~tavasti/ you can find 3 video clips for
> testing. Create video from them like:
>
> ffmpeg -f concat -safe 0 -i <(for i in FHD*MOV; do echo file $(pwd)/$i;
> done)  -an -filter:v "setpts=0.003*PTS" x333.mp4
>
> And there you have the flickering. Sure, amount of test material might
> be bit overscaled :-)

I don't have permissions to download, get 403 error.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Markku Tavasti
On 19.04.2017 23:28, Paul B Mahol wrote:

> On 4/19/17, Markku Tavasti <[hidden email]> wrote:
>>  From http://scl1.tavasti.fi/~tavasti/ you can find 3 video clips for
>> testing. Create video from them like:
>>
>> ffmpeg -f concat -safe 0 -i <(for i in FHD*MOV; do echo file $(pwd)/$i;
>> done)  -an -filter:v "setpts=0.003*PTS" x333.mp4
>>
>> And there you have the flickering. Sure, amount of test material might
>> be bit overscaled :-)
>
> I don't have permissions to download, get 403 error.

Sorry, stupid me not checking. Now they should work. Sorry.

--Tavasti

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filter for smoothening gradual luminance changes?

Paul B Mahol
On 4/20/17, Markku Tavasti <[hidden email]> wrote:

> On 19.04.2017 23:28, Paul B Mahol wrote:
>> On 4/19/17, Markku Tavasti <[hidden email]> wrote:
>>>  From http://scl1.tavasti.fi/~tavasti/ you can find 3 video clips for
>>> testing. Create video from them like:
>>>
>>> ffmpeg -f concat -safe 0 -i <(for i in FHD*MOV; do echo file $(pwd)/$i;
>>> done)  -an -filter:v "setpts=0.003*PTS" x333.mp4
>>>
>>> And there you have the flickering. Sure, amount of test material might
>>> be bit overscaled :-)
>>
>> I don't have permissions to download, get 403 error.
>
> Sorry, stupid me not checking. Now they should work. Sorry.

I applied deflicker filter to the master.

It smooths global luminance variations only. For local one, like for
stuff in shadows
use it in combination with atadenoise filter.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Loading...