Raspberry Pi online course

Record Slow-Motion Video with a Raspberry Pi Camera

Learn how to record 640×480 video at 90 FPS with raspivid, save it as an H.264 stream, and play the result in VLC as slow motion.

Slow motion is created by recording more frames per second than the frame rate used for playback. For example, a camera can capture 90 frames per second (FPS), while the video is played at a conventional lower rate such as 30 FPS. The same action then takes approximately three times longer to display.

A frame rate is the number of individual image frames captured or displayed each second. FPS means frames per second. The capture frame rate and playback frame rate are separate settings: capture determines how much motion detail is recorded, while playback determines how quickly those frames are shown.

Resolution describes the pixel dimensions of each frame, expressed as width by height. Higher capture rates commonly require reduced resolution because the camera and Raspberry Pi must process and store more frames every second.

Requirements

  • A compatible Raspberry Pi Camera Module.
  • The camera ribbon cable connected firmly, with the correct orientation, to the Raspberry Pi camera connector.
  • The camera enabled or otherwise made available to the operating system. On systems that provide the setting, see Enable Camera in raspi-config.
  • A Raspberry Pi terminal and basic command-line knowledge. The Terminal in Raspbian lesson covers the basics.
  • The legacy Raspberry Pi camera command-line utility raspivid.
  • Enough storage space for the output file and a well-lit scene.

High-frame-rate capture mode

This worked example uses 640 by 480 pixels at 90 FPS. It is a practical balance between frame rate and image detail: the frame rate is high enough to capture fast movement clearly, while the resolution is lower than many ordinary video modes.

Available modes depend on the Raspberry Pi model, camera model, lighting, firmware or camera software, and the selected resolution. A particular camera may not support 90 FPS at 640 by 480, or may offer high-speed recording only at another resolution.

Record a 10-second slow-motion source clip

Open a terminal, change to the directory where you want the recording saved, and run:

raspivid -w 640 -h 480 -fps 90 -t 10000 -o slowMotion.h264

The command records for 10 seconds and creates slowMotion.h264 in the current working directory. The result is an H.264 elementary stream: a raw compressed video stream without a container such as MP4.

Command options explained

OptionExample valuePurpose
-w640Sets the output frame width to 640 pixels.
-h480Sets the output frame height to 480 pixels.
-fps90Requests a capture rate of 90 frames per second.
-t10000Sets the capture duration to 10,000 milliseconds, which is 10 seconds.
-oslowMotion.h264Chooses the output filename. The file is written to the current directory.

Keep the camera still or aim it at an event such as a bouncing ball, falling object, splash, or quick hand movement. Start the command just before the action occurs. When recording finishes, check that the file exists in the current directory using ordinary file-management commands.

Capture setting trade-offs

SettingBenefitTrade-off
Higher frame rateCaptures more stages of fast movement and allows greater slow-down during playback.Often requires lower resolution, more light, and a camera mode that supports the requested rate.
Higher resolutionProduces more image detail and larger frames.May reduce the maximum available frame rate and increase processing or storage requirements.
Longer recording durationProvides more time to catch an unpredictable event.Creates a larger file and uses more storage space.

Play the recorded H.264 file

VLC is a media player that can open many video formats, including H.264 streams. If it is not installed, use a network connection and administrator privileges to run:

sudo apt-get install vlc

Use the system's current package-management conventions if they differ. After installation, open VLC from the desktop menu or terminal and choose Open File. Select slowMotion.h264 from the directory where the command was run.

Simply opening the stream may not automatically create an obvious slow-motion effect. The camera captured at 90 FPS, but the player might interpret or display the stream at its capture rate. To see the intended effect, play the captured frames at a conventional lower rate, such as 30 FPS. At 90 FPS capture and 30 FPS playback, a 10-second capture contains about 900 frames and takes about 30 seconds to display.

If the player does not provide a playback-rate control for the elementary stream, remux or transcode the recording with an explicitly selected playback frame rate using suitable video tools. This can also place the stream in a more widely supported container.

Troubleshooting

The camera command cannot access the camera

  • Power off the Raspberry Pi and check that the ribbon cable is not loose, reversed, or connected to the wrong interface.
  • Check that the camera is enabled and recognized by the operating system.
  • Confirm that the installed camera software provides the legacy raspivid utility. A newer camera stack may require a different command.

The requested 90 FPS mode does not work

The camera or Raspberry Pi model may not support this mode, or the selected width, height, and frame rate may be an unsupported combination. Try a supported camera mode, reduce the resolution, or choose a lower frame rate.

The video is too dark or blurry

At a high frame rate, each frame commonly has less available exposure time. Fast movement in low light can therefore appear dark or blurred. Increase scene lighting, avoid strong backlighting, and aim at a brighter area of the subject.

The H.264 file will not open or does not appear slow

Try VLC or another player with H.264 support. If the file opens but plays at normal speed, the player may be using the capture rate rather than a lower playback rate. Use playback-rate control or remux or transcode the clip with an explicitly chosen lower frame rate.

VLC installation fails

Check the network connection, refresh package information when appropriate, and repeat the installation with administrator privileges. The command requires an internet connection and permission to install system packages.

Key points

  • Slow motion depends on the difference between capture FPS and playback FPS.
  • The example command captures 640 by 480 video at 90 FPS for 10,000 milliseconds.
  • slowMotion.h264 is an H.264 elementary video stream in the current working directory.
  • High frame rates often require lower resolution and better lighting.
  • Camera hardware and software determine which modes are actually available.