H264 vs H265

Hello Guys!

Just a quick question on this. I saw that H265 is able to reduce bandwidth and storage as compared to H264 of about 50% given same bitrate and pipeline. However, when I run the pipeline, I realized that they are about the same with no significant decrease in bandwidth and filesize. Am I doing it right? Below are the pipeline I used.

RTSP Both constant at about 1Mbps upload on network
H265:

./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, framerate=20/1 ! nvvidconv ! nvv4l2h265enc control-rate=1 bitrate=8000000 !  rtph265pay name=pay0 pt=96 config-interval=1"

H264:

./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, framerate=20/1 ! nvvidconv ! nvv4l2h264enc control-rate=1 bitrate=8000000 ! rtph264pay name=pay0 pt=96 config-interval=1"

Filesink Both file size is about 13MB for about 10 seconds of recording
H265:

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=3264, height=2464, framerate=20/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! h265parse ! qtmux ! filesink location=filename_h265.mp4 -e

H264:

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=3264, height=2464, framerate=20/1' ! nvv4l2h264enc control-rate=1 bitrate=8000000 ! h264parse ! qtmux ! filesink location=filename_h264.mp4 -e

Hope that you guys can help me out! Thanks!

Hi,
8Mbps is strict for 3264x2464p20, suggest you try higher bitrate such as 14Mbps.

Hi @DaneLLL,

Ive change the bitrate to 14000000 and also 30000000. Both H264 and H265 are streaming at the same rate. There are no significant decrease for H265.

Hi,
For comparing h264 and h265, please use same YUV source and compare PSNR.
For example, you may download the source:
https://media.xiph.org/video/derf/y4m/park_joy_1080p50.y4m
Run

$ gst-launch-1.0 filesrc location= park_joy_1080p50.y4m ! y4mdec ! nvvidconv ! nvv4l2h264enc bitrate=14000000 control-rate=0 vbv-size=450000 ! h264parse ! qtmux ! filesink location= park_joy.mov
$ gst-launch-1.0 filesrc location= park_joy_1080p50.y4m ! y4mdec ! nvvidconv ! nvv4l2h265enc bitrate=14000000 control-rate=0 vbv-size=450000 ! h265parse ! qtmux ! filesink location= park_joy_265.mov

And install/run ffmpeg to check PSNR

$ gst-launch-1.0 filesrc location= park_joy_1080p50.y4m ! y4mdec ! filesink location=park_joy_50.yuv
$ sudo apt install ffmpeg
$ ffmpeg -i park_joy.mov -f rawvideo -video_size 1920x1080 -framerate 50 -i park_joy_50.yuv -lavfi "ssim;[0:v][1:v]psnr" -f null -       ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  (...skip)
[Parsed_ssim_0 @ 0x55c102f010] SSIM Y:0.713943 (5.435473) U:0.732030 (5.719138) V:0.788833 (6.753741) All:0.729439 (5.677350)
[Parsed_psnr_1 @ 0x55c102eda0] PSNR y:24.882475 u:30.801891 v:34.448052 average:26.262739 min:22.971376 max:30.380294

Hi @DaneLLL, How about RTSP streaming? Im trying to achieve a significant drop in my network bandwidth utilisation with the help of h265. But currently, both are at the same rate. Thanks!

Hi,
It is ~0.6dB difference in quality when comaparing in same 14Mbps. A slight improvement. So for keeping in same quality, bitrate also does not differ a lot. You may set a lower bitrate and configure

> preset-level        : HW preset level for encoder
                        flags: readable, writable, changeable only in NULL or READY state
                        Enum "GstV4L2VideoEncHwPreset" Default: 1, "UltraFastPreset"
                           (0): DisablePreset    - Disable HW-Preset
                           (1): UltraFastPreset  - UltraFastPreset for high perf
                           (2): FastPreset       - FastPreset
                           (3): MediumPreset     - MediumPreset
                           (4): SlowPreset       - SlowPreset

See if you can balance quality, bitrate, and performance by adjusting the properties.

Hi DaneLLL, managed to get it by using omx instead. The difference is by half. But on nvv4l2, I guess the codec has already been tuned. Another question is that if jetson nano can support 16MP camera module for usb3.0 and if there will be any performance issues. Thanks!

Hi,
The maximum resolution verified is 4K and max width of encoder is 4096. We would like to suggest use 4K as maximum.

Hi DaneLLL, thanks for the response. Also, have you tried videocapture opencv python flask with h265? Or it is not possible to do so?

Hi,
There are posts about using cv2.VideoWriter:
https://devtalk.nvidia.com/default/topic/1067612/jetson-nano/how-can-i-integrate-my-live-streaming-gstreamer-pipeline-with-opencv-/post/5407842/#5407842

However, we would suggest this solution:
https://devtalk.nvidia.com/default/topic/1073127/jetson-nano/opencv-videowriter-to-nvdrmvideosink-fps-drops/post/5436732/#5436732

FYR.

Hi DaneLLL, thanks but can opencv stream to browser an encoded live capture? Also, when I’m running tensorflow example, my cpu usage peak. I’m suspecting it’s python that’s causing the high utilization as tensorflow, keras are using Gpu instead. Am I right to say so? Thanks!

Hi,

Not sure about this. May need forum users to share suggestion.

You may run sudo tegrastats to confirm whether it runs on CPU or GPU.
Besides, we have DeepStream SDK for doing deep learning inference.
https://docs.nvidia.com/metropolis/index.html
You may install it through SDKManager and try.