Video Frame Extraction with ffmpeg

Originally published at: Video Frame Extraction with ffmpeg - RICOH THETA Developer Community

I took videos with a RICOH THETA SC2 and converted the video into still images, using 1 frame every 2 seconds.


Save Image Every 5 to 10 Feet

At the speed I’m walking, there is a distance of 5 to 10 feet between frames.

Here’s another sequence of two frames that show the distance I’m travelling between frames.

Rotating the two spheres above, you can see how my perspective relative to the tree changes. You can use the corner of the walkway as a reference point.

The original video file used in the test was 330MB. I converted the video file into 24 frames.

Using the same from from the example above and rotating it to the perspective used for standard viewing, the image quality is good.

This is the same frame rotated upward.

Convert 330MB Video File into 5.2MB Archive File

Each frame is between 200KB and 375KB.

Using zip archival format, I compressed all 24 image files into a single 5.2MB compressed file.

This is a big decrease from the original 330MB file.

Convert 30fps Video into 1 Frame Every 2 Seconds

In the example below, the original RICOH THETA SC2 video file name is R0012344.MP4.

# 1 frame every 2 seconds

ffmpeg -i R0012344.MP4 -r 1/2 frames/R0012344-%05d.jpg

-i specifies the input filename.

-r specifies the number of frames per number of seconds. In this example, the video file will be converted to 1 frame every 2 seconds.

%05d.jpg will attach 5 numbers in sequence after the filename.

Convert 30fps Video into 1fps Video

If you want to convert the video file at 30fps into a video file at 1fps, use the command below.

ffmpeg -i R0012343.MP4  -filter:v fps=1 R0012343_1fps.mp4

Next Steps with ffmpeg

I’ve only run the ffmpeg command on WSL on Windows.

In the future, I would like to try using it on Android. The Flutter package ffmpeg_kit_flutter looks like it may help me to run ffmpeg on Android.

1 Like