Jetson Linux API Reference

32.7.1 Release
10_camera_recording (libargus capture)


This sample demonstrates how to use libargus to set up the camera class components for a capture operation. An EGLStream is also created to connect to the V4L2 video encoder to allow for capturing encoded video streams to a file.

Building and Running


To build:

  • Enter:
     $ cd /usr/src/jetson_multimedia_api/samples/10_camera_recording
     $ make
    The sample creates the H.264 video file in the current directory.

To run

  • Enter:
     $ ./camera_recording [OPTIONS]

To view supported options

   $ ./camera_recording -h


The following diagram shows the flow of data through this sample.

This sample demonstrates the camera producer and consumer programming model. The image output is performed using the EGLStream. This is an efficient and zero-copy output to various EGLStream consumers. Possible consumers include:

  • OpenGL ES
  • CUDA
  • Direct EGL display output
  • JPEG

Key Structure and Classes

The following classes are used. For more information on libargus and the EGLStream, refer to the libargus documentation.

Classes Description
class NvVideoEncoder The class contains all the video encode related elements and functions.

The NvVideoEncoder class packages all the video encoding related elements and functions. The key members used in the sample are as follows:

NvVideoEncoder Description
output_plane V4L2 output plane.
capture_plane V4L2 capture plane.
createVideoEncoder Static function to create video encode object.
setExtControls Sets the external control to the V4L2 device.
setOutputPlaneFormat Sets the output plane format.
setCapturePlaneFormat Sets the capture plane format.
isInError Checks if under an error state.

The NvVideoEncoder class contains two key elements:

  • output_plane
  • capture_plane

The NvVideoEncoder object is derived from the following class type:

The key members used in the sample are as follows:

NvV4l2ElementPlane Description
setupPlane Sets up the plane of the V4L2 element.
deinitPlane Destroys the plane of the V4L2 element.
setStreamStatus Starts/stops the stream.
setDQThreadCallback Sets the callback function of the dqueue buffer thread.
startDQThread Starts the thread of the dqueue buffer.
stopDQThread Stops the thread of the dqueue buffer.
qBuffer Queues the V4L2 buffer.
dqBuffer Dqueue the V4L2 buffer.
getNumBuffers Gets the number of V4L2 buffers.
getNthBuffer Gets the nth number V4L2 buffer.