Reply to topic

Plugin to correct glitchy frames (ponctual flickering).

pparent
Registered Member
Posts
16
Karma
0
Hi,

I would like to write a plugin or a script to correct glitchy frames: on some DSLRs there are sometimes micro-bugs in auto-exposure in video mode, which results once in a while with a frame with a completely different exposure than the others in the movie, resulting in a punctual flickering and flash feeling for the viewer. (It happens for example with gradual exposure in magic lantern on canon 550d). I've already seen this kind of glitchy frames on professional videos of conferences on youtube, so I guess I'm not the only one with that problem.

The purpose would be to detect theses glitchy frames, simply by detecting frames that have very different luminosity in comparison to both the previous and the next one.

Once we have detected the glitchy frames we can replace them with previous frame, or if possible correct luminosity of that frame, to the mean of the next and previous frame so that it does not flash anymore.

Do you have any comment on how hard this would be to do, or any advice?

Thank's in advance,
Pierre.
pparent
Registered Member
Posts
16
Karma
0
I've done this script which is probably far from optimal, but which already gives good results for me:

Code: Select all
#!/bin/sh

mkdir tmp
cd tmp

ffmpeg -i ../$1 -r 25 -qscale:v 1 -q:v 1 outputFile_%d.jpg
ffmpeg -i ../$1 -vn -acodec flac output-audio.flac

next=0
value=0
previous=0
for i in $( seq 1 1500); do
previous=$value;
value=$next;
next=$(convert outputFile_$i.jpg -colorspace Gray -format "%[mean]" info: | sed "s/\..*//g")

diff1=$(( value - previous ))
diff2=$((  next - value ))
diffbetweendiffs=$((  diff2 + diff1 ))
#abs value
diffbetweendiffsabs=${diffbetweendiffs#-}

if [ $diff1 -gt 1000 ]&&  [ $diff2 -lt -1000 ] && [ $diffbetweendiffsabs -lt 1000 ]; then
    echo "Correcting frame $(( i-1 ))";
    cp outputFile_$(( i-2 )).jpg outputFile_$(( i-1 )).jpg   
fi

if [ $diff2 -gt 1000 ]&&  [ $diff1 -lt -1000 ] && [ $diffbetweendiffsabs -lt 1000 ]; then
    echo "Correcting frame $(( i-1 ))"
    cp outputFile_$(( i-2 )).jpg outputFile_$(( i-1 )).jpg
fi

done

ffmpeg -r 25 -i outputFile_%d.jpg -i output-audio.flac -vcodec copy  ../out.avi
cd ..
rm -r tmp/

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], kdetefo, leolist, Majestic-12 [Bot], parked, Sogou [Bot], Yahoo [Bot]