Multimedia API example hangs on lossless encode of random data

Hey,

the 01_video_encode example hangs when using the --elossless flag while encoding random data. It works with all-zero data, and without the lossless flag.

Reproduce as follows:

  1. Create raw input files with random data and all zeros. 100 frames 1920x1200 YUV444 = 100*1920*1200*3 = 691200000 bytes:
dd bs=6912 count=100000 </dev/zero >zero.yuv444
dd bs=6912 count=100000 </dev/urandom >random.yuv444
  1. Encode the raw files lossy as a sanity check (I think this assumes YUV420?):
./video_encode zeros.yuv444 1920 1200 H264 zeros.h264
./video_encode random.yuv444 1920 1200 H264 random.h264
  1. (OPTIONAL) look at the .h264 files with e.g. ffplay, they are encoded properly
  2. Encode the raw files losslessly:
./video_encode zeros.yuv444 1920 1200 H264 zeros.h264lossless --elossless
./video_encode random.yuv444 1920 1200 H264 random.h264lossless --elossless
  1. Observe that encoding works with zero file (can be played with ffplay)
    but random file encoding hangs:
Creating Encoder in blocking mode 
Opening in BLOCKING MODE
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
875967048
875711833
H264: Profile = 244, Level = 51 
NVMEDIA_ENC: bBlitMode is set to TRUE 
NvVideoEncTransferOutputBufferToBlock: DoWork failed line# 667 
NvVideoEnc: NvVideoEncTransferOutputBufferToBlock TransferBufferToBlock failed Line=678

Interestingly, the program even segfaults when run with time in front:

time ./video_encode random.yuv444 1920 1200 H264 random.h264lossless --elossless
Creating Encoder in blocking mode 
Opening in BLOCKING MODE
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
875967048
875711833
H264: Profile = 244, Level = 51 
NVMEDIA_ENC: bBlitMode is set to TRUE 
Segmentation fault (core dumped)

This was run on Xavier NX with /etc/nv_tegra_release:

# R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t186ref, EABI: aarch64, DATE: Fri Feb 19 16:50:29 UTC 2021

For context, we need to encode 12 bit gray data with highest possible quality. We plan to use YUV444, using the Y channel for the 8 highest bits, and the U channel for the 4 lowest bits. The Y channel data will look like a proper image, but the U channel will look quite random. Therefore we wanted to see if lossless coding with random data works, and what the file size and encoding performance would be. Hence the comparison with all zero data and time.

This was originally suggested for 8 bit data by @DaneLLL in this thread.

If you have other suggestions for lossless 12 bit gray encoding, I am all ears :)

Hi,
Please set each byte to 0x80 in U and V planes and try again. The two planes will be encoded so it is not good to be random bytes.

Yes, it works without noisy data. I can put an 8 bit video in either the luma or the chroma channels, with the other channels being zero or 0x80. Just noisy data makes it crash.

My idea about encoding 12 bit data in 8 bits of luma and 4 of chroma does not work, because the lower bits look like noise. Just wanted to report the crash of the sample application.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.