00_video_decode sample with HEVC

When I used sample to test the Hevc decoding, I found that the sample program did not obtain the file descriptor when VIDIOC_EXPBUF, which resulted in the inability to obtain the memory pointer when calling the mmap function.

How to decode HEVC.

Do you hit any issue in video decoding? The buffers at output plane are memory-mapped and some veriables in the structure are not required.

The code in my screenshot is the code of sample. In sample, we need to obtain fd first, and then obtain the memory pointer according to fd.

However, this operation is OK when H264 is decoded, and fd cannot be obtained when HEVC is decoded.

The sample code is like this. How can I decode the Hevc video correctly?

It seems not required to call VIDIOC_EXTBUF in output plane. Please check read_decoder_input_nalu() and read_decoder_input_chunk(). If you follow the sample code, you can get buffer pointer stored in buffer->planes[0].data

I develop my program based on the decoder_unit_sample.

When I use the decoder_unit_sample to test hecv, sample will report the file descriptor error of VIDIOC_EXPBUF

Do you observe the error on Jetpack 4.6.2 or 5.0.2?

it’s Jetpack 5.0.2

By default the sample is hard coded to decoding H264 stream. After modifying and rebuilding the sample, we can run it successfully on Jetpack 4.6.2 and 5.0.2:

/usr/src/jetson_multimedia_api/samples/unittest_samples/decoder_unit_sample$ ./decode_sample /home/nvidia/basketball_1080p_4mbps.265 a.yuv
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279
Starting capture thread
Input file read complete
Resolution: 1920x1080
Decoder colorspace ITU-R BT.601 with standard range luma (16-235)
Query and set capture successful
Resource unavailable
Resource unavailable
Exiting decoder capture loop thread
Decoder Run is successful

The decoded YUV looks fine. Could you follow the samples for development?

Can I have a copy of the basketball_1080p_4mbps.265 file?
I want to try it.

There is a video file in DeepStream SDK. Please extract h265 stream by running:

$ gst-launch-1.0 filesrc location= /opt/nvidia/deepstream/deepstream-6.1/samples/streams/sample_1080p_h265.mp4 ! qtdemux ! h265parse ! 'video/x-h265,stream-format=byte-stream' ! filesink location= a.265

Command not executed successfully

It looks like you don’t install DeepStream SDK. Please execute $ ls /opt/nvidia/deepstream and check if the package exists. If not, please install it through SDKManager.

If you use Xavier NX with emmc module and the roofs is on emmc, the freespace is not enough for installing it. Please note this.

After installing DeepStream, I obtained the hevc video file.

However, an error is reported when using sample to extract yuv data.

Do you modify and rebuild the sample to decode H265 stream?

Yes, I used the following command to generate the 265 file

You would need to grep V4L2_PIX_FMT_H264 in decoder_unit_sample, modify them to H265, and re-compile the sample.

I did this at first, but after I changed it to 265, I could not get the file descriptor.

Refer to the first picture I sent.


Please change to V4L2_PIX_FMT_H265 instead of V4L2_PIX_FMT_HEVC

I experimented and found that V4L2_PIX_FMT_H265 was OK after use, and errors would be reported when using V4L2_PIX_FMT_HEVC.
It’s amazing.
Isn’t HEVC and H265 the same? And V4L2_PIX_FMT_H265 and V4L2_PIX_FMT_HEVC belong to different header files.

We use V4L2_PIX_FMT_H265 in our v4l2 stack, so please set to V4L2_PIX_FMT_H265 for decoding H265 stream.