<p>The following worked well for me, based on the same ideas</p>

<p><a href="http://www.premiumbeat.com/blog/quick-trick-for-de-flickering-your-video-shots/" rel="noreferrer">http://www.premiumbeat.com/blog/quick-trick-for-de-flickering-your-video-shots/</a></p>

<p><a href="https://superuser.com/questions/1025794/merge-two-videos-with-transparency-in-ffmpeg">https://superuser.com/questions/1025794/merge-two-videos-with-transparency-in-ffmpeg</a></p>

<p>It's more than a year, so I don't remember exactly how I arrived at this. The VOB was a video shot from a projected screen with serious projector pulldown flicker, alternating lighter and darker frames. The VOB was interlaced at 29.970 fps, where 1 frame would be 0.033 sec. The result was amazingly good, way beyond what I could get with various other deflicker filters.</p>

<p><code>ffmpeg -fflags +genpts -i FLICKER.VOB -fflags +genpts -i FLICKER.VOB -filter_complex "[0:v]setpts=PTS-STARTPTS[top]; [1:v]setpts=PTS-STARTPTS+.033/TB, format=yuva420p, colorchannelmixer=aa=0.5[bottom]; [top][bottom]overlay=shortest=1" -c:v libx264 -crf 26 -an NOFLICKER.mp4</code></p>

CC BY-SA 4.0
2018-12-01T21:26:17.607Z
This solution seems to provide better results than OP's, but beware that the `-an` option is irrelevant here and will actually remove sound (or to quote the manpage : "Disable audio recording").
Skippy le Grand Gourou
CC BY-SA 4.0
2024-01-18T15:50:59.223Z
The idea here is it's blending the brightness of consecutive frames. That will fix flickering at the framerate, but will all produce ghosting for fast-moving objects.
OrangeDog
CC BY-SA 3.0
2018-04-08T14:45:37.127Z
2018-04-11T01:29:28.430Z
2018-04-11T01:29:28.430Z
niscove
<p>I have video footage shot at shutter speeds of 1/30s under artificial light here in Europe where the AC is 50Hz. Flicker occurs -- obviously I should have used 1/25s or 1/50s but I didn't, and want to save the footage.</p>

<p>I have tried different ffmpeg filters but none did work: <a href="https://ffmpeg.org/ffmpeg-filters.html#deflicker" rel="noreferrer">deflicker</a> for example is made specifically to remove frame-by-frame luminance changes (e.g., what happens in timelapse videos) but not to fix the banding that I see due to using a shutter speed not in sync with the frequency of the AC feeding the light bulb.</p>

<p>I have found some obscure reference to other ffmpeg filters like <a href="https://ffmpeg.org/ffmpeg-filters.html#toc-hqdn3d-1" rel="noreferrer">hqdn3d</a> but the defaults did not work and I don't really understand how to play with the parameters and how to relate them to my specific case.</p>

<p>I'm looking for a command-line/open source solution (hence, ffmpeg) because my video editor is pretty basic (iMovie) and will not allow me to do tricks like shifting and blending footage.</p>

<p><strong>UPDATE</strong></p>

<p>I have found a 'quick tip' on <a href="http://philipbloom.net/blog/newyorksnow/" rel="noreferrer">Philip Bloom's blog</a> that says:</p>

<blockquote>
  <p>[...] my quick trick fix [...] is simply duplicating layers, shifting top layer over by a frame and adding 50% opacity to it.</p>
</blockquote>

<p>So I have spent an hour figuring out the arcane syntax of ffmpeg and tried to replicate the above steps:</p>

<pre><code>$ ffmpeg -i FLICKER.mov -itsoffset 0.1 -i FLICKER.mov \
-filter_complex "[1:v]format=yuva420p,colorchannelmixer=aa=0.5[b]; \
[0:v][b]overlay" -map 0:1 NOFLICKER.mov
</code></pre>

<p>With this command I input twice the same input file, the second one is shifted by 0.1 second (<code>-itsoffset 0.1</code>), a 0.5 transparency is applied in the <code>-filter_complex</code> argument (<code>[1:v]</code> means the video stream of the second file) and then overlaid on top of the video stream of the first file (<code>[0:v]</code>). The audio track is simply copied from the first file (<code>-map 0:1</code>).</p>

<p>The good news is that this works as expected, no more flickering. The problem is that I had to offset the second copy too much (0.1 seconds) so I have a very clear and evident shadow effect on my final output, not a faint and what would be acceptable motion blur if only I had it shifted by a single frame like in the Bloom's recipe above.</p>

<p>I think that is due to the fact that my original footage is not high-fps but only 24 fps. A shift of a single frame would have meant <code>-itsoffset 0.0416</code> (1/24 s = 0.0416 s) and that shift doesn't really do anything. I've also tried to understand why a 0.1 second shift is so effective, but could not come up with any reasonable explanation (I thought that could have been related to the AC frequency is 1/50 Hz but that would've meant that a shift of 0.02 seconds would do something...).</p>

<p>Anyway, the problem remains. I could think of a possible solution where perhaps I could instruct ffmpeg to leave a user-selected portion of the footage free from the overlay and simply copy the original stream (that's because it's a footage of my daughter talking under artificial lights, and the flickering is very disturbing on the borders of the frame where it's all dark, but her face is relatively free from the flicker), or again, like I asked before, find one of the many filters in ffmpeg to work its charm.</p>

CC BY-SA 3.0
2018-02-12T16:05:28.200Z
Is the camera fixed?
Gyan
CC BY-SA 3.0
2018-02-12T20:54:54.007Z
@Mulvya yes the camera was fixed in place while shooting.
Alessandro Amato del Monte
<ffmpeg><sync><lighting>
Remove flickering due to artificial light with ffmpeg
Alessandro Amato del Monte
# Remove flickering due to artificial light with ffmpeg

(Asked by: username_0 on 2018-02-09)

I have video footage shot at shutter speeds of 1/30s under artificial light here in Europe where the AC is 50Hz. Flicker occurs -- obviously I should have used 1/25s or 1/50s but I didn't, and want to save the footage.
I have tried different ffmpeg filters but none did work: deflicker for example is made specifically to remove frame-by-frame luminance changes (e.g., what happens in timelapse videos) but not to fix the banding that I see due to using a shutter speed not in sync with the frequency of the AC feeding the light bulb.
I have found some obscure reference to other ffmpeg filters like hqdn3d but the defaults did not work and I don't really understand how to play with the parameters and how to relate them to my specific case.
I'm looking for a command-line/open source solution (hence, ffmpeg) because my video editor is pretty basic (iMovie) and will not allow me to do tricks like shifting and blending footage.
UPDATE
I have found a 'quick tip' on Philip Bloom's blog that says:

[...] my quick trick fix [...] is simply duplicating layers, shifting top layer over by a frame and adding 50% opacity to it.

So I have spent an hour figuring out the arcane syntax of ffmpeg and tried to replicate the above steps:
$ ffmpeg -i FLICKER.mov -itsoffset 0.1 -i FLICKER.mov \
-filter_complex "[1:v]format=yuva420p,colorchannelmixer=aa=0.5[b]; \
[0:v][b]overlay" -map 0:1 NOFLICKER.mov

With this command I input twice the same input file, the second one is shifted by 0.1 second (-itsoffset 0.1), a 0.5 transparency is applied in the -filter_complex argument ([1:v] means the video stream of the second file) and then overlaid on top of the video stream of the first file ([0:v]). The audio track is simply copied from the first file (-map 0:1).
The good news is that this works as expected, no more flickering. The problem is that I had to offset the second copy too much (0.1 seconds) so I have a very clear and evident shadow effect on my final output, not a faint and what would be acceptable motion blur if only I had it shifted by a single frame like in the Bloom's recipe above.
I think that is due to the fact that my original footage is not high-fps but only 24 fps. A shift of a single frame would have meant -itsoffset 0.0416 (1/24 s = 0.0416 s) and that shift doesn't really do anything. I've also tried to understand why a 0.1 second shift is so effective, but could not come up with any reasonable explanation (I thought that could have been related to the AC frequency is 1/50 Hz but that would've meant that a shift of 0.02 seconds would do something...).
Anyway, the problem remains. I could think of a possible solution where perhaps I could instruct ffmpeg to leave a user-selected portion of the footage free from the overlay and simply copy the original stream (that's because it's a footage of my daughter talking under artificial lights, and the flickering is very disturbing on the borders of the frame where it's all dark, but her face is relatively free from the flicker), or again, like I asked before, find one of the many filters in ffmpeg to work its charm.

**Tags:** ffmpeg, sync, lighting

> **Comments:**
> **username_1**: Is the camera fixed?  
> **username_0**: @Mulvya yes the camera was fixed in place while shooting.  

---

## 1 answers

### Answer by username_2 on 2018-04-08. Score: 9

The following worked well for me, based on the same ideas

<http://www.premiumbeat.com/blog/quick-trick-for-de-flickering-your-video-shots/>

<https://superuser.com/questions/1025794/merge-two-videos-with-transparency-in-ffmpeg>

It's more than a year, so I don't remember exactly how I arrived at this. The VOB was a video shot from a projected screen with serious projector pulldown flicker, alternating lighter and darker frames. The VOB was interlaced at 29.970 fps, where 1 frame would be 0.033 sec. The result was amazingly good, way beyond what I could get with various other deflicker filters.

`ffmpeg -fflags +genpts -i FLICKER.VOB -fflags +genpts -i FLICKER.VOB -filter_complex "[0:v]setpts=PTS-STARTPTS[top]; [1:v]setpts=PTS-STARTPTS+.033/TB, format=yuva420p, colorchannelmixer=aa=0.5[bottom]; [top][bottom]overlay=shortest=1" -c:v libx264 -crf 26 -an NOFLICKER.mp4`

> **Comments:**
> **username_3**: This solution seems to provide better results than OP's, but beware that the `-an` option is irrelevant here and will actually remove sound (or to quote the manpage : "Disable audio recording").  
> **username_4**: The idea here is it's blending the brightness of consecutive frames. That will fix flickering at the framerate, but will all produce ghosting for fast-moving objects.  

---

