L4T Multimedia API Reference

28.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages


This sample demonstrates how to render video stream or UI with the NVIDIA® Tegra® Direct Rendering Manager (DRM). This sample provides rendering support on non-X11 and lightweight display systems. The DRM is implemented in user-space and is compatible with DRM 2.0.

A DRM is a subsystem of the Linux kernel that interfaces with GPUs.

The sample supports two running modes, depending on the --disable-video option:

  • If specified, the sample draws only the UI on the screen. The UI is a static JPEG image and a moving color block.
  • Otherwise, it displays both the decoded video stream and the UI.

The sample demonstrates the supported DRM buffer allocation policies:

  • Allocated by user. UI stream uses this policy.
  • Allocated by other V4L2 components (decoder or converter), where memory is shared with DRM. Video stream uses this policy.

The sample supports these video formats:

  • H.264
  • H.265

Building and Running


To build:

  • Enter:
     $ cd $HOME/tegra_multimedia_api/samples/08_video_dec_drm
     $ make

To run

  • Enter:
     $ ./video_dec_drm <in-file> <in-format> [options]

To view supported options

   $ ./video_dec_drm --help

Example: To render only the UI stream

./video_decode_drm --disable-video

Example: To render only the video stream

./video_decode_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --disable-ui

Example: To render the UI and video streams

./video_decode_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264


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

Flow of Data Through the Sample

The following diagram shows the interactions between the separate threads in the sample.

Thread Processing

Main Thread

If the options include --disable-video, the sample does the following:

  1. Creates DRM renderer for drawing UI.


  1. Creates the decoder and converter for conversion from YUV422/BL to NV12/PL.
  2. Sets up the decoder output plane.
  3. Feeds data into the decoder output plane, until the EOS is reached.


  1. Sets up decoder capture plane and converter output/capture plane based on the modes user requested.
  2. Creates DRM renderer.
  3. Decodes and converts.
  4. Dequeues the buffer into the DRM for display.


  1. Draws a static Image on the second plane (the first plane is used for video streaming).
  2. Draws a moving color block on the third plane.


  1. Dequeues the buffer from DRM and returns it to the converter capture plane.
    Because the DRM dequeue operation is a blocking call, you must make the call in separate thread from the enqueue operation.
  2. Detects whether EOS has been reached.

Key Structure and Classes

The following tables shows the key classes and functions that this sample uses.

Class Description
class NvDrmRenderer Contains elements and functions to render frames with tegra DRM.
class NvVideoDecoder Contains all video decoding-related elements and functions.
class NvVideoConverter Contains elements and functions for video format conversion.

ui_render_loop_fcn Thread function to render the UI image.
renderer_dequeue_loop_fcn Thread function to dequeue the flipped frame from NvDrmRenderer().
conv0_capture_dqbuf_thread_callback Callback function to enqueue a new frame into NvDrmRenderer.
conv0_output_dqbuf_thread_callback Callback function to receive a frame from decoder and process format conversion.