Ads

Saturday 1 February 2014

Convert videos to images with FFmpeg.

Convert videos to images with FFmpeg

FFmpeg is a wonderful do-all audio/video transcoding tool and it can also be used to extract images from video. Grab the latest Win32/static version from tinyurl.com/lrcvz7k and in the \bin folder, you’ll find the ‘ffmpeg.exe’ command line executable. Start by opening up Windows Explorer and launching a Command Prompt within that ‘\bin’ subfolder (hold down the Shift key, right-click in the ‘\bin’ subfolder area and select ‘Open command window here’ from the context menu.) Next, use the following command line:
Ffmpeg –i “c:\path\to\file\video.file” –r 1 –s 480x480 –f image2 “c:\path\to\image-=.jpg”
Here’s what that does:
  1. -r 1 tells FFmpeg to capture one frame per second of video.
  2. -s 480x480 tells it to create 480 x 480-pixel images from each of the captured frames.
  3. -f image2 tells FFmpeg to create images from each captured frame.
  4. image-=.jpg tells it we want images stored numerically with three-digit numbers created in JPEG format.

Replace \path\to\file paths with the appropriate paths for your files.
It’s important that you include the full path to your video input file and the location where you want the images stored. If the file path includes any spaces, you must surround the whole path with double quote marks; for example: ffmpeg –i “c:\new path\videonext.avi” . If you don’t, it won’t work. Also, the save location folder path must exist already — FFmpeg won’t create the folder for you and will simply fail.
The other important thing is that the frame size you select will also set the aspect ratio. For example, 480 x 480 pixels will produce square frames that will probably look a bit ‘tall’. In this case, 480 x 270 or 720 x 406 would be a better option if you’re using a 16:9 aspect ratio video. For 4:3 aspect video, you’d use something like 480 x 360 or 720 x 540. Just divide the horizontal resolution you want by 1.7778 to get the correct vertical resolution for 16:9 video and by 1.333 for a 4:3 video.

No comments:

Post a Comment