Extracting frames from video

Lijo Jose
1 min readJun 28, 2019

--

This article discusses about golang wrapper for ffmpeg for extracting frames from video.

FFmpeg is a great software package a media developer should have. The kind of configurability this provides is uncomparable in media domain. Out of vast capabilities, this article discusses how one can extract frames from video.

  • The key idea in extracting the frames using ffmpeg involves specifiying the output file name. Here, we need to specify the filename with extendable naming pattern like %04d. This will extend the naming from 0001 to 9999 .
  • Next we need to specify the rate at which these frames to be generated. We use video filters available with ffmpeg. The filter we use is fps .

Below is the sample command to extract the frames.

ffmpeg -i <input file> -vf fps=3 <out-dir>/frame%04d.jpg

Go wrapper

For using the ffmpeg frame extraction programmatically, we need to write one wrapper. I chose Go as I want to put this in AWS Lambda Function with extra functionalities. (Will write about that later).

I forked go ffmpeg wrapper from https://github.com/yale8848/gffmpeg (I liked the builder pattern used here) and modified. The updated version is available https://github.com/lijo-jose/gffmpeg.

The complete usage is available here.

--

--