Accelerated HW Decode with ffmpeg not working,Decoder h264 does not support device type cuda

i am using jetson agx board, and i want to Accelerated Decode with ffmpeg hw decoder, i download ffmpeg library in L4T builds according to the link:
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fmultimedia.html%23wwpID0E0JB0HA

  1. run the command
    $ 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
    sudo apt update
    sudo apt install ffmpeg
  2. and then i found the download ffmpeg example at /usr/share/ffmpeg/examples/
    and compiler the hw_decoder.c
  3. run hw_decoder bin file, ./hw_decode cuda …/…/video/sample_0.mp4 output.yuv
    but i get the error : Decoder h264 does not support device type cuda.

why this happend, hope for your answer, thanks!

@renfeierxulifei

You may refer to the topic The NVIDIA ffmpeg package supports hardware-accelerated decode on Jetson platforms - #11 by mdegans.

it seemed that the topic :
The NVIDIA ffmpeg package supports hardware-accelerated decode on Jetson platforms
can not answer my question, i was wandering why i run the hw_decoder bin file, give me the error Decoder h264 does not support device type cuda.

Pls refer to ffmpeg-4.2.2/libavcodec/nvv4l2_dec.c which is the right way you can access the decoder engine in current release.

1 Like
  1. do you mean i call nvv4l2 dec api by myself refering to ffmpeg-4.2.2/libavcodec/nvv4l2_dec.c ?if so, is there concrete samples how to call api wrapper in nvv4l2_dec.c, since there are only some api wrapper in nvv4l2_dec.c
  2. do you mean i should not call ffmpeg api refer to ffmpeg example hw_decoder.c? i think call ffmpeg api directly is simple

Hi,
Please refer to the command:

$ ffmpeg -c:v h264_nvv4l2dec -i h264_1080p_high_30mbps_30fps.mp4 -c:v rawvideo -pix_fmt yuv420p out.yuv

Thanks for your quick reply! But, since we need to use hwdecoder in our source code, which means we need API level doc/user guide. Could you help on this?

thank you for the reply, i want to complete HW decoder with cuda by code in our project, rather than ffmpeg command, so we write the hw decoder code refer to the installed ffmpeg example hw_decoder.c, but it not work. could you tell me why the hw_decoder.c not work or could you give us the other sample code guid?

Hi,
Would like to clarify that hardware encoding/decoding is not executed on GPU(CUDA). On Jetson platforms, there are individual hardware encoding/decoding engines. Beside ffmpeg, you may try gstreamer or jetson_multimedia_api. Please check the documents for detail.
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Faccelerated_gstreamer.html%23
https://docs.nvidia.com/jetson/l4t-multimedia/index.html

hi, DaneLLL
we use ffmpeg api for HW decoder in our project, could you give us user guide based ffmpeg api , detailed sample code is better

Hi,

You may refer to
Jetson Linux API Reference: Main Page | NVIDIA Docs
Jetson Linux API Reference: Main Page | NVIDIA Docs

They are the right sample code to demonstrate how to leverage HW decode engine and work with CUDA in the same time. It’s different with the CUDA on X86 Host as @DaneLLL said , multi engine or processor need the special APIs to work with each other efficiently.

You can directly get MMAPI lib installed with SDKmanger or you also can try with Gstreamer which has hw decoder plugin integrated.

hi, we only want to use ffmpeg api, since using ffmpeg api can reduce AGX porting cost of our project software. and the link: Welcome — Jetson Linux<br/>Developer Guide 34.1 documentation
say the NVIDIA ffmpeg package supports hardware-accelerated decode on Jetson platforms.
please help us solve the problem encoutered using ffmeg api, see the first post.

Hi,
The reference command is share in the comment. Please give it a try. You can execute sudo tegrastats to check if NVDEC is enabled.

For developing the application, please check the source code to know how h264_nvv4l2dec works.

hi, i execute sudo tegrastats, display:
RAM 6128/31919MB (lfb 501x4MB) SWAP 0/15959MB (cached 0MB) CPU [1%@1190,0%@1190,0%@1190,0%@1190,1%@1190,0%@1190,0%@1190,0%@1190] EMC_FREQ 0%@1600 GR3D_FREQ 0%@318 APE 150 MTS fg 0% bg 1% AO@31.5C GPU@32.5C Tdiode@35.25C PMIC@100C AUX@31.5C CPU@32C thermal@31.95C Tboard@33C GPU 152/152 CPU 304/304 SOC 912/912 CV 0/0 VDDRQ 456/456 SYS5V 1680/1680

if we modify the source code, then we need to compiler ffmpeg package by ourself, so could you provider the right compiler option?

Hi,
Please check the steps of downloading source code in

And the steps to configure/make/run ffmpeg with hardware decoding in
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-June/263746.html