Camera GStream Video

Recording and streaming video

Make sure the module is connected to a network. Next, find the IP address of the receiving end by running ifconfig on the receiving machine. Then, on the receiving machine, start to listen with:

gst-launch-1.0 -e udpsrc port=5001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, a-framerate=(string)30.000000, a-framesize=(string)1920-1080" ! rtph264depay ! avdec_h264 ! autovideosink

On the module, use the following command to record video from the camera and stream it to the receiving machine:

gst-launch-1.0 icamerasrc num-buffers=300 device-name=0 io-mode=3 printfps=true ! video/x-raw,format=NV12,width=1920,height=1080 ! vaapih264enc tune=low-power dmabuf-alloc-tiled=true ! h264parse ! rtph264pay ! udpsink host=0.0.0.0 port=5001

Make sure to replace 0.0.0.0 with the IP address of the receiving machine.

It is possible to run both cameras simultaneously and show the viewfinder for each of them on the compute module hardware. Listen with two instances of the same command given above but change the port number on one of them to 5002. Then start the streaming with:

gst-launch-1.0 icamerasrc num-buffers=300 device-name=1 io-mode=1 printfps=true ! video/x-raw,format=NV12,width=1920,height=1080 ! queue ! tee name=t2 ! queue ! vaapih264enc tune=low-power dmabuf-alloc-tiled=true ! h264parse ! rtph264pay ! udpsink host=0.0.0.0 port=5002 t2. ! vaapisink dmabuf-alloc-tiled=true icamerasrc num-buffers=300 device-name=0 io-mode=1 printfps=true ! video/x-raw,format=NV12,width=1920,height=1080 ! queue ! tee name=t ! queue ! vaapih264enc tune=low-power dmabuf-alloc-tiled=true ! h264parse ! rtph264pay ! udpsink host=0.0.0.0 port=5001 t. ! vaapisink dmabuf-alloc-tiled=true

 

H.265/HEVC video encoding

Recording video compressed with the H.265/HEVC encoder is possible for the following resolutions and framerates. One example is given:

640x480@30fps, 1280x720@30fps, 1920x1080@30fps

 

gst-launch-1.0 -e icamerasrc num-buffers=300 device-name=0 io-mode=3 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! vaapih265enc dmabuf-alloc-tiled=true ! h265parse ! matroskamux ! queue ! filesink location=test.mkv

 

VP8 video encoding

Recording video compressed with the VP8 encoder is possible for the following resolutions and framerates. One example is given:

640x480@30fps, 1280x720@30fps, 1920x1080@30fps

gst-launch-1.0 -e icamerasrc num-buffers=300 device-name=0 io-mode=3 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! vaapivp8enc dmabuf-alloc-tiled=true ! webmmux ! queue ! filesink location=test.webm

Digital Video Stabilization (DVS)

DVS is supported up to 720p resolutions for both viewfinding and video recording. It is enabled by adding the video-stabilization-mode=1 option to the icamerasrc.

gst-launch-1.0 icamerasrc num-buffers=300 device-name=1 io-mode=3 video-stabilization-mode=1 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! vaapisink dmabuf-alloc-tiled=true

 

For more complete information about compiler optimizations, see our Optimization Notice.