LinuxCommandLibrary

rpicam-vid

Record video using a Raspberry Pi camera

TLDR

Capture a 10 second video

$ rpicam-vid [[-t|--timeout]] 10000 [[-o|--output]] [path/to/file.h264]
copy

SYNOPSIS

rpicam-vid [options] -o <output_file>

PARAMETERS

-o, --output <file>
    Specifies the output file path for the recorded video. This option is mandatory for saving video to disk.

-t, --timeout <ms>
    Sets the video recording duration in milliseconds. A value of 0 means infinite recording until interrupted by user input (e.g., Ctrl+C or --keypress).

-w, --width <pixels>
    Sets the width of the captured video resolution.

-h, --height <pixels>
    Sets the height of the captured video resolution.

-f, --framerate <fps>
    Sets the target frame rate for video capture.

--codec <name>
    Specifies the video encoding codec. Common options include h264, h265, or mjpeg.

-q, --quality <level>
    Sets the video encoding quality (0-100). Higher values result in better quality but larger file sizes.

--bitrate <bps>
    Sets the target bitrate for video encoding in bits per second.

--nopreview
    Disables the live preview window on the attached display.

--vflip
    Vertically flips the camera image.

--hflip
    Horizontally flips the camera image.

--exposure <mode>
    Sets the exposure mode (e.g., auto, normal, sport, long).

--awb <mode>
    Sets the auto white balance mode (e.g., auto, incandescent, fluorescent).

--listen
    Enables network streaming by listening for incoming client connections (default port 8000).

--tcp | --udp
    Specifies the network protocol for streaming when --listen is enabled (TCP or UDP).

--keypress
    Allows stopping recording by pressing the Enter key in the terminal.

DESCRIPTION

rpicam-vid is the dedicated command-line application for recording video using the camera module connected to a Raspberry Pi.
It leverages the modern libcamera API, offering a robust and flexible solution for video capture, succeeding the older raspivid utility. This tool supports various video formats (H.264, H.265, MJPEG), resolutions, and frame rates. It provides extensive control over camera parameters such as exposure, gain, white balance, and more.
Beyond local file recording, rpicam-vid can stream video over a network and display a live preview, making it versatile for both simple video capture and more complex streaming applications. It's an essential utility for anyone doing video work on a Raspberry Pi.

CAVEATS

rpicam-vid requires a Raspberry Pi with a compatible camera module and a recent version of Raspberry Pi OS (e.g., Bullseye or newer) with the libcamera stack enabled. Performance metrics such as resolution and frame rate are dependent on the specific Raspberry Pi model and camera sensor capabilities.

LIVE PREVIEW AND DISPLAY

By default, rpicam-vid displays a live preview of the camera feed on the attached display. This can be useful for framing shots or monitoring the video capture. The preview can be disabled using the --nopreview option.

NETWORK STREAMING CAPABILITIES

The command has built-in capabilities to stream the video over TCP or UDP using options like --listen, --port, --tcp, or --udp. This makes it suitable for remote monitoring, surveillance, or integration into network-based video applications without needing external streaming tools.

HISTORY

rpicam-vid emerged as part of the transition of Raspberry Pi camera software from the legacy MMAL (Multi-Media Abstraction Layer) stack to the modern open-source libcamera framework. This shift began around Raspberry Pi OS Bullseye. It specifically replaced the older raspivid command, offering improved stability, broader camera support, and better integration with standard Linux multimedia frameworks. It represents a significant step towards a more open and maintainable camera stack for the Raspberry Pi.

SEE ALSO

rpicam-still(1), rpicam-raw(1), rpicam-hello(1), raspivid(1), libcamera-vid(1), ffmpeg(1)

Copied to clipboard