How to Extract Image Frames from a Video File
Let’s say you have a video file that may be a scene from a DVD movie, a clip that you downloaded from YouTube, or something that you captured with your webcam. Here are some ways by which you can extract (still) image frames from the video file.
Option 1. If you want to save only a few frames from the video, you may do that manually using your existing media player itself – see detailed instructions on how to capture images from videos.
Option 2. If you wish to capture a sequence of images from the video, you may either use GOM Media Player or if your video file in the AVI format, use AV Cutty which will export the entire video in a series of image frames.
Option 3. Then there’s the popular VLC Media Player which is available on Windows, Mac and Linux and let you extract images through the command line. The good part about VLC is that it supports all the popular Video formats without you have to install codecs separately.
Here’s the command for extracting images using VLC:
C:\VideoLAN\VLC>vlc "C:\videos\hello.mov" --video-filter=scene --vout=dummy --start-time=1 --stop-time=5 --scene-ratio=1 --scene-prefix=img- --scene-path=C:\images\ vlc://quit
How VLC command works?
hello.mov is the full path of the video file while
C:\images is the directory where we want to save the video thumbnails. The scene prefix is img meaning are thumbnails will be numbered as img1.jpg, img2.jpg and so on. The start and stop time specifies the time in seconds while the scene-ratio means that we want to output one image per frame.
Option 4. Finally, here’s something I prefer though it again involves the command line. Download the Win32 binary of ffmpeg here, extract the file and then use the following command to make image thumbnails of any video file.
c:\ffmpeg.exe -i c:\video\hello.mov – ss 10 – t 4 -f image2 – sameq -vcodec mjpeg img-%03d.jpg
How ffmpeg command works?
You specify the video path and file name with the – i parameter while – ss denotes the time from where you want to start extracting the image frames. The – t parameter denotes the video duration that should be converted into image thumbnails while img-%03d means that the output files will be named as img-001.jpg and so on. You get better quality image thumbnails with the – sameq parameter.
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.