<p>Use the <a href="http://www.ffmpeg.org/ffmpeg-filters.html#blackframe" rel="nofollow noreferrer">blackframe</a> and <a href="http://www.ffmpeg.org/ffmpeg-filters.html#metadata_002c-ametadata" rel="nofollow noreferrer">metadata</a> filters after select.</p>
<pre><code>ffmpeg -i &quot;$video_file&quot; -filter:v &quot;select=bitor(gt(scene\,0.5)\,eq(n\,0)),blackframe=amount=1,metadata=mode=select:key=lavfi.blackframe.pblack:value=95:function=less&quot; -vsync drop &quot;$frames_dir/%04d.jpg&quot;
</code></pre>

CC BY-SA 4.0
2023-08-18T04:20:02.457Z
2023-08-18T04:20:02.457Z
Gyan
<p>I'm using this command to create screenshots from a video, each time there is a frame change.</p>
<p><code>ffmpeg -i &quot;$video_file&quot; -filter_complex &quot;select=bitor(gt(scene\,0.5)\,eq(n\,0))&quot; -vsync drop &quot;$frames_dir/%04d.jpg&quot;</code></p>
<p>It seems to work pretty well, but there are a few black images in the screenshots that I'd like to remove.</p>
<p>I'm not well versed in advanced ffmpeg commands and I think the command above can be adapted to throw away the black frames. Does anybody know how?</p>

<ffmpeg>
How to filter out black frames from ffmpeg command that takes screenshots?
progonkpa
# How to filter out black frames from ffmpeg command that takes screenshots?

(Asked by: username_0 on 2023-08-17)

I'm using this command to create screenshots from a video, each time there is a frame change.

`ffmpeg -i "$video_file" -filter_complex "select=bitor(gt(scene\,0.5)\,eq(n\,0))" -vsync drop "$frames_dir/%04d.jpg"`

It seems to work pretty well, but there are a few black images in the screenshots that I'd like to remove.

I'm not well versed in advanced ffmpeg commands and I think the command above can be adapted to throw away the black frames. Does anybody know how?

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2023-08-18. Score: 1 | Accepted answer

Use the blackframe and metadata filters after select.
ffmpeg -i "$video_file" -filter:v "select=bitor(gt(scene\,0.5)\,eq(n\,0)),blackframe=amount=1,metadata=mode=select:key=lavfi.blackframe.pblack:value=95:function=less" -vsync drop "$frames_dir/%04d.jpg"


---

