A lot of people ask if our Custom Training or Visual Search products can train and search on videos, and unfortunately, we have to say that these are both restricted to images at the moment. However, that doesn't mean that you can't use the videos and turn them into a collection of images! Let's examine how to do that.
There are several external tools on the web that can take a video and smash it up into a bunch of images, but the one that we prefer to use is called FFMPEG. And it's actually super easy to install and use.
FFMPEG has a few nifty things that it can do, but for the sake of what we're trying to do here, let's focus on splitting videos into a collection of images.
Step 1: Install FFMPEG
There are packages available for Linux, Mac and Windows, or if you prefer you can git clone the source code with:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
Step 2: Split The Videos!
Now here's the easy (and useful!) part. To split a video into still frames all you need to do is call something like the following:
ffmpeg -i file.mpg -vf fps=1 out%03d.jpg
The parameters:
- The video file that you want to split (file.mpg here)
- A frames-per-second number (fps=1)
- An output filename format for the resulting images (out%03d.jpg)
You'll also notice the -i (input) and -vf (video filter) options above and those can essentially be left alone. They're necessary and you won't need to adjust that.
And voila! Once this is run you'll get a bunch of out%03d.jpg files in the same folder as the original video file.
Full FFPMEG Documentation:
https://www.ffmpeg.org/ffmpeg.html
Happy Video Splitting!