Accelerated Decode with ffmpeg
The NVIDIA ffmpeg package supports hardware-accelerated decode on NVIDIA® Jetson™ device.
An application can use accelerated decode to read video files in the following elementary formats and container formats and dump them in YUV 420 format:
H.264
H.265
VP8
VP9
MPEG2
MPEG4
Note
The ffmpeg package does not support MPEG4 container files.
To install the ffmpeg binary package
Enter this command:
$ sudo apt install ffmpeg
To get source files for the ffmpeg package
Enter this command:
$ apt source ffmpeg
To include the ffmpeg library in Jetson Linux builds
Add the following lines to /etc/apt/sources.list:
$ echo "deb https://repo.download.nvidia.com/jetson/ffmpeg main main" | sudo tee -a /etc/apt/sources.list $ echo "deb-src https://repo.download.nvidia.com/jetson/ffmpeg main main" | sudo tee -a /etc/apt/sources.list
Enter this command:
$ sudo apt update
Decode Functional Flow
This section describes the function flow of the ffmpeg decoding process:
Call
nvv4l2dec_init_decoder()to create a new V4L2 Video Decoder object on the device node/dev/nvhost-nvdec.Call
subscribe_event()to subscribe to resolution change events.Call
set_output_plane_format()to set the format on the output plane.Call
capture_thread()to start a capture thread.Call
set_capture_plane_format()to set the format on the capture plane.Call
nvv4l2dec_decode()to read buffers from ffmpeg and start the decode process.Call
nvv4l2dec_decoder_get_frame()to get the hardware-accelerated decoded data and pass it toffmpegfor dumping.Call
nvv4l2dec_decoder_close()to destroy the buffers and close the device.
The following table describes the key structure.
Element  | 
Description  | 
|---|---|
nvPacket  | 
Contains information about input packets.  | 
nvFrame  | 
Contains information about decoded frames.  | 
nvCodingType  | 
Specifies a different codec type.  | 
BufferPlane  | 
Holds the buffer plane parameters.  | 
Buffer  | 
Holds the buffer information.  | 
context_t  | 
Defines the decoder context.  | 
This table describes the key function:
Element  | 
Description  | 
|---|---|
nvv4l2dec_create_decoder  | 
Creates a new V4L2 Video Decoder object on the
device node   | 
subscribe_event  | 
Subscribes to resolution change events.  | 
set_output_plane_format  | 
Sets the format on the output plane.  | 
req_buffers_on_output_plane  | 
Requests buffers on the output plane to be filled from the input bit stream.  | 
dq_buffer  | 
Dequeues the V4L2 buffer.  | 
q_buffer  | 
Queues the V4L2 buffer.  | 
capture_thread  | 
Starts the capture thread.  | 
dq_event  | 
Dequeues an event reported by the V4L2 device.  | 
req_buffers_on_capture_plane  | 
Requests buffers on the capture plane.  | 
set_capture_plane_format  | 
Sets the capture plane format.  |