NvV4L Encoder: Extreme fluctuations in encoding time


I have an application which captures frames from a Basler camera at 25FPS, encodes them as H265 video using the NvV4L encoder and transmits the video over UDP sockets.
Each frame’s resolution is: 1920x1080

I measured the time it takes to encode each frame, and I can see that when the target encoding bitrate is raised from 2Mbps towards the 10Mbps the encoding time starts to fluctuate, and reaches extreme values.
I ran the test both on a Jetson AGX & a Jetson NX, with similar results:

When the resolution was 1920x1080 and target bitrate was around 2Mbps , the results were fairly stable (though much higher than expected):
Jetson NX: 20-40ms per frame
Jetson AGX: 20-25ms per frame

When the resolution was 1920x1080 but target bitrate was raised to 10Mbps , the results were extremely high and with great fluctuations on both Jetsons , with most frames taking 35-40ms to encode, but some frames taking even as much as 100ms or longer to encode, and the values were fluctuating all over the place.

For comparison’s sake, the same application (but using the NvEnc Encoder) on an x86 laptop, with GeForce GTX 1650:
With Encoder’s target bitrate set to 10Mbps, it consistently takes 5-10 milliseconds to encode each frame, with no fluctuations (measured Encoding time for several thousand frames and all values were 5-10ms).

Additional information:

me@jetson:~$ uname -a
Linux jetson 4.9.140-tegra #1 SMP PREEMPT Thu Sep 24 16:09:59 PDT 2020 aarch64 aarch64 aarch64 GNU/Linux

Please see attached a snippet of our CPP code, showing the parameters we configure for the Encoder.
Any input or suggestions would be much appreciated.

Thank you,
NvV4L_encoder_code.cpp (1.9 KB)

The code looks partial and cannot be built/run. Could you check if you can make a patch on 01_video_encode so that we can run and reproduce the issue? This would help investigate the issue further.

And please share the release version( $ head -1 /etc/nv_tegra_release ).

Release version (it’s the same on both my Jetson AGX & my Jetson NX):

me@jetson:~$ head -1 /etc/nv_tegra_release
# R32 (release), REVISION: 4.3, GCID: 21589087, BOARD: t186ref, EABI: aarch64, DATE: Fri Jun 26 04:34:27 UTC 2020

The code I attached above indeed cannot be compiled solo, it is a snippet of code out of a large project.
I am now looking into patching 01_video_encode. Will update shortly.


EDIT: I managed to create a YUV which 01_video_encode can work with, so the following post can be ignored.

I followed this thread in the forum and managed to create a YUV which 01_video_encode can work with.

I guess that “Could not read complete frame from input file” is printed even when the frame is encoded successfully…


I am having trouble running the 01_video_encode app.

Nvidia’s docs give the following example:

   $ ./video_encode ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 H264 sample_outdoor_car_1080p_10fps.h264

However, the file sample_outdoor_car_1080p_10fps.yuv does not exist in the suggested path (…/…/data), nor anywhere else on the Jetson (that’s true for both my Jetson NX & Jetson AGX).
When I try running the app on one of my own 1920x1080 YUV files, e.g:

./video_encode ~/evil-frank.yuv 1920 1080 H264 ~/evil-frank.h264

I get the following result:

Creating Encoder in blocking mode 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
H264: Profile = 66, Level = 51 
Could not read complete frame from input file
File read complete.
[ERROR] (NvV4l2ElementPlane.cpp:178) <enc0> Capture Plane:Error while DQing buffer: Broken pipe
Segmentation fault (core dumped)

You can see attached the results of running the same command with --stats --dbg-level 3:
01_video_encode.log (5.5 KB)

Here is the (zipped) core file which was created:
core.zip (1.4 MB)

Is there somewhere I can download the sample_outdoor_car_1080p_10fps.yuv file from?
Or can I use one of the other sample applications to create the YUV file from the sample_outdoor_car_1080p_10fps.h264 file which I do have?

It will be a great help if you can help me get the 01_video_encode app to run, then I can use it as a comparison to my own application, as well as provide you with runnable code for assessment.


Please decode the h264 to get the sample YUV and try again:

nvidia@nvidia-desktop:/usr/src/jetson_multimedia_api/samples/00_video_decode$ sudo ./video_decode H264 --disable-rendering -o ../../data/Video/sample_outdoor_car_1080p_10fps.yuv ../../data/Video/sample_outdoor_car_1080p_10fps.h264