Find Dark Intervals
Finds sections in a video with sufficient darkness. Works without relying on complex machine learning solutions.
How it works
- Takes an input video file and splits it into image frames using ffmpeg.
- Computes a mean grayscale color value for each frame using ImageMagick.
- Identifies sufficiently dark frames using standard score.
- Computes start/end timeframes for dark segments and trims the original video.
What can this be used for?
Quickly finding points of interest in a video that correspond to changes in brightness.
Installation
Install it yourself as:
gem install find_dark_intervals
Usage
Make sure you have a recent version of ffmpeg
and convert
in your PATH
.
On Mac, they can be installed using Homebrew:
brew update
brew install ffmpeg imagemagick
Then in irb
, run:
require 'find_dark_intervals'
FindDarkIntervals::IntervalsFinder.new('your/video/path.mp4').run
After some time, you should see a new file <video_name>_highlights.mp4
in the
same directory as the original video.