Jetson Linux API Reference

35.5.0 Release
08_video_dec_drm (Direct Rendering Manager)


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), where memory is shared with DRM. Video stream uses this policy.

The sample supports these video formats:

  • H.264
  • H.265

Building and Running


  • This sample must be run without desktop. Please open a console via SSH or serial connection.
  • You have followed Steps 1-3 in Building and Running.
  • If you are building from your host Linux PC (x86), you have followed Step 4 in Building and Running.

To build:

  • Enter:
     $ cd /usr/src/jetson_multimedia_api/samples/08_video_dec_drm
     $ make

Reassign display windows for Jetson AGX Xavier and Jeson Xavier NX:

  • Since this sample requires two overlay DRM planes and by default Jetson AGX Xavier only has 1 overlay plane for each CRTC, assign 1 primary and 5 overlay planes by below command for Jetson AGX Xavier.
     $ sudo sh -c 'echo 4 > /sys/class/graphics/fb1/blank'
     $ sudo sh -c 'echo 4 > /sys/class/graphics/fb2/blank'
     $ sudo sh -c 'echo 4 > /sys/class/graphics/fb0/blank'
     $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb1/device/win_mask'
     $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb2/device/win_mask'
     $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb0/device/win_mask'
     $ sudo sh -c 'echo 0x3f > /sys/class/graphics/fb0/device/win_mask'
     $ sudo sh -c 'echo 0 > /sys/class/graphics/fb0/blank'

Ensure the Ubuntu desktop is disabled:

   $ sudo systemctl stop gdm
   $ sudo loginctl terminate-seat seat0

Install nvidia-drm driver for Jetson Orin:

   $ sudo modprobe nvidia-drm modeset=1

If there are two display outputs, unblank the second inactive display:

   $ sudo sh -c 'echo 0 > /sys/class/graphics/fb1/blank'

To run

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

To view supported options

   $ ./video_dec_drm --help

Example: To render only the UI stream

   $ sudo ./video_dec_drm --disable-video

Example: To render only the video stream

   $ sudo ./video_dec_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --disable-ui

Example: To render the UI and video streams

   $ sudo ./video_dec_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264

Enable the Ubuntu desktop after run

   $ sudo systemctl start gdm


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.
  2. Sets up the decoder output plane.
  3. Feeds data into the decoder output plane, until the EOS is reached.


  1. Sets up the decoder capture plane and the converter based on the modes that the user requested.
  2. Creates DRM renderer.
  3. Decodes and converts.
  4. Passes 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.
    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.

Function Description
ui_render_loop_fcn Thread function to render the UI image.
renderer_dequeue_loop_fcn Thread function to dequeue the flipped frame from NvDrmRenderer().