RASPIVID(1)

NAME
raspivid - records H264 video with the Pi Camera Module

SYNOPSIS
raspivid [-3d mode] [-3dswap] [-ISO value] [-a flags|text] [-ae size,fg,bg] [-ag value] [-awb mode] [-awbg b,r] [-b bps] [-br value] [-c] [-cd name] [-cfx u:v] [-co value] [-cs camera] [-d ms] [-dg value] [-dn screen] [-drc value] [-e] [-ev value] [-ex mode] [-f] [-fl] [-fli mode] [-fps fps] [-g frames] [-gps] [-h size] [-hf] [-i state] [-if type] [-ifx effect] [-ih] [-k] [-l] [-lev level] [-md mode] [-mm mode] [-n] [-o filename] [-op opacity] [-p x,y,w,h] [-pf profile] [-pts filename] [-qp num] [-r filename] [-rf format] [-roi x,y,w,h] [-rot value] [-s] [-sa value] [-set] [-sg ms] [-sh value] [-sl num] [-sn num] [-sp] [-ss value] [-stm] [-t ms] [-td on,off] [-v] [-vf] [-w size] [-wr num] [-x filename]
raspivid [-?]
raspivid [--help]

DESCRIPTION
raspivid is a command line utility for recording video from the Raspberry Pi Camera Module (any version). It has numerous options which can be used to customize the recording, the preview display, or to perform more complex operations like circular buffering and video streaming.

OPTIONS
The options documented in the following sections are specific to the raspivid utility, or commonly used with it. For full details of the other options (which are common to all the camera utilities), please refer to the raspicam(7) manual page.

GENERAL OPTIONS

-?, --help
    Display a concise description of all parameters

-b, --bitrate bps
    Use bits per second, so 10Mbits/s would be -b 10000000. For H264, 1080p30 a high quality bitrate would be 15Mbits/s or more. Maximum bitrate is 25Mbits/s (-b 25000000), but much over 17Mbits/s won't show noticeable improvement at 1080p30.

-c, --circular
    Select circular buffer mode. All encoded data is stored in a circular buffer until a trigger is activated, then the buffer is saved.

-cd, --codec name
    Specifies the encoder codec to use. Options are H264 and MJPEG. H264 can encode up to 1080p, whereas MJPEG can encode upto the sensor size, but at decreased framerates due to the higher processing and storage requirements.

-d, --demo [ms]
    This options cycles through the range of camera options. No recording is taken, and the demo will end at the end of the timeout period, irrespective of whether all the options have been cycled. The time between cycles should be specified as a millisecond value.

-fl, --flush
    Forces a flush of output data buffers as soon as video data is written. This bypasses any OS caching of written data, and can decrease latency.

-fps, --framerate fps
    Specifies the frames per second to record. At present, the minimum frame rate allowed is 2fps, and the maximum is 30fps. This is likely to change in the future.

-h, --height size
    Set the video height to size.

-if, --irefresh type
    Sets the H264 intra-refresh type. Possible types are:

    •   cyclic

    •   adaptive

    •   both

    •   cyclicrows

-i, --initial state
    Define whether the camera will start paused or will immediately start recording. Valid states are record or pause. Note that if you are using a simple timeout (without --timed or --keypress or other options to activate recording), and --initial is set to pause, no output will be recorded.

-ih, --inline
    Forces the stream to include PPS and SPS headers on every I-frame. Needed for certain streaming cases e.g. Apple HLS. These headers are small, so don't greatly increase the file size.

-g, --intra frames
    Sets the intra refresh period (GoP) rate for the recorded video. H264 video uses a complete frame (I-frame) every intra refresh period, from which subsequent frames are based. This option specifies the number of frames between each I-frame. Larger numbers here will reduce the size of the resulting video, and smaller numbers make the stream less error-prone.

-k, --keypress
    On each press of the Enter key, the recording will be paused or restarted. Pressing X then Enter will stop recording and close the application. Note that the timeout value (-t) will be used to signal the end of recording, but is only checked after each Enter keypress; so if the system is waiting for a keypress, even if the timeout has expired, it will still wait for the keypress before exiting.

-lev, --level level
    Specifies the H264 encoder level to use for encoding. Options are 4, 4.1, and 4.2.

-l, --listen
    When using a network connection as the --output, this option will make the sytem wait for a connection from the remote system before sending data.

-o, --output filename
    Specify the output filename. If not specified, no file is saved. If the filename is “-”, then all output is sent to stdout. To connect to a remote IPv4 host, use tcp or udp followed by the required IP Address. e.g. tcp://192.168.1.2:1234 or udp://192.168.1.2:1234.

    To listen on a TCP port (IPv4) and wait for an incoming connection use the --listen option, e.g. raspivid -l -o tcp://0.0.0.0:3333 will bind to all network interfaces, raspivid -l -o tcp://192.168.1.1:3333 will bind to a local IPv4.

-e, --penc
    Switch on this option to display the preview after compression. This will show any compression artefacts in the preview window. In normal operation, the preview will show the camera output prior to being compressed. This option is not guaranteed to work in future releases.

-pf, --profile profile
    Sets the H264 profile to be used for the encoding. Options are:

    •   baseline

    •   main

    •   high

-qp, --qp num
    Sets the initial quantisation parameter for the stream. Varies from approximately 10 to 40, and will greatly affect the quality of the recording. Higher values reduce quality and decrease file size. Combine this setting with a bitrate of 0 to set a completely variable bitrate.

-r, --raw filename
    Specify the output file name for any raw data files requested.

-rf ,--raw-format format
    Specify the raw format to be used if raw output is requested. Valid formats are yuv, rgb, and grey. grey simply saves the Y channel of the YUV image.

-pts, --save-pts filename
    Saves timestamp information to the specified file. Useful as an input file to mkvmerge(1).

-sg, --segment ms
    Rather than creating a single file, the file is split into segments of approximately the number of milliseconds specified. In order to provide different filenames, you should add %04d or similar at the point in the filename where you want a segment count number to appear e.g:

        --segment 3000 -o video%04d.h264

    will produce video clips of approximately 3000ms (3s) long, named “video0001.h264”, “video0002.h264” etc. The clips should be seamless (no frame drops between clips), but the accuracy of each clip length will depend on the intraframe period, as the segments will always start on an I-frame. They will therefore always be equal or longer to the specified period.

    The most recent version of raspivid will also allow the file name to be time-based, rather than using a segment number. For example:

        --segment 3000 -o video_%c.h264

    will produce file names formatted like so: “video_Fri Jul 20 16:23:48 2018.h264”

    There are many different formatting options available - see strftime(3) for a full list. Note than the %d and %u options are not available, as they are used for the segment number formatting, and that some combinations may produce invalid file names.

-s, --signal
    Sending a USR1 signal to the raspivid process will toggle between recording and paused. This can be done using the killall(1) command, as below:

        killall -USR1 raspivid

    Note that the timeout value will be used to indicate the end of recording, but is only checked after each receipt of the USR1 signal; so if the system is waiting for a signal, even if the timeout has expired, it will still wait for the signal before exiting.

-sl, --slices num
    Sets the number of horizontal slices per frame. The default is 1 (no slices).

-sp, --split
    When in --signal or --keypress mode, each time recording is restarted, a new file is created.

-stm, --spstimings
    Insert timing information into the SPS block.

-sn, --start num
    When outputting segments (with --segment), this is the initial segment number, giving the ability to resume a previous recording from a given segment. The default value is 1.

-td, --timed on,off
    This options allows the video capture to be paused and restarted at particular time intervals. Two values are required: the on time and the off time, both measured in milliseconds. On time is the amount of time the video is captured, and off time is the amount it is paused. The total runtime of the application is defined by the timeout option (-t). Note that the runtime may go slightly over the timeout setting depending on the on and off times.

    For example:

        raspivid -o test.h264 -t 25000 --timed 2500,5000

    This will alternate between recording for 2500ms (2.5s), then pausing for 5000ms (5s) gaps, until 25000ms (25s) have elapsed. The resulting recording will only be 10s long, since 4 segments of 2.5s = 10s, separated by 3 gaps of 5s = 15s, for a total of 25s:

        Seconds            1                   2
         1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
        RRRRR..........RRRRR..........RRRRR..........RRRRR

-t, --timeout ms
    The total length of time that the program will run for. If not specified, the default is 5000ms (5 seconds). If set to 0, the application will run indefinitely until stopped with Ctrl-C.

-x, --vectors filename
    Turns on output of motion vectors from the H264 encoder to the specified file name.

-v, --verbose
    Outputs debugging/information messages during the program run.

-wr, --wrap num
    When outputting segments, this is the maximum the segment number can reach before it's reset to 1, giving the ability to keep recording segments, but overwriting the oldest one. So if set to 4, in the --segment example above, the files produced will be “video0001.h264”, “video0002.h264”, “video0003.h264”, and “video0004.h264”. Once “video0004.h264” is recorded, the count will reset to 1, and “video0001.h264” will be overwritten.

EXIT STATUS

0   Application ran successfully (EX_OK)

64  Bad command line parameter (EX_USAGE)

70  Software or camera error (EX_SOFTWARE)

130 Application terminated by Ctrl-C

EXAMPLES
Image size and preview settings are the same as for still captures. The default size for video recording is 1080p (1920x1080).

raspivid -t 5000 -o video.h264
    Record a 5s clip with default settings (1080p30).

raspivid -t 5000 -o video.h264 -b 3500000
    Record a 5s clip at a specified bitrate (3.5Mbits/s).

raspivid -t 5000 -o video.h264 -f 5
    Record a 5s clip at a specified framerate (5fps).

raspivid -t 5000 -o -
    Encode a 5s camera stream and send the image data to stdout.

raspivid -t 5000 -o - > my_file.h264
    Encode a 5s camera stream and send the image data to a file.

SEE ALSO
raspicam(7), raspistill(1), raspividyuv(1), raspiyuv(1), vcgencmd(1), [SOURCE]

REFERENCES

[SOURCE]
    https://www.raspberrypi.org/documentation/raspbian/applications/camera.md