Comparing H.265 to H.264H compression (a quick test)

tmxv4128

Getting comfortable
Jan 28, 2022
143
304
California
I wondered what the best encoding setting would be for a Color 4K-T180, so this afternoon I took some screenshots of a zoomed in target (street speed sign)at various compression/bit rates. H.264H @ 14336 bit rate seemed to be the best choice for this camera. H.265 had noticeable artifacts.
 

Attachments

  • Encoding-Comparison.jpg
    Encoding-Comparison.jpg
    1.7 MB · Views: 47
What you would be experiencing with the H265 is "macroblocking" of non-moving areas.

H265 in theory provides more storage as it compresses differently, but part of that compression means it macro blocks big areas of the image that it thinks isn't moving. That can be problematic for digital zooming with H265.

However, it also takes more processing power of the already small CPU in the camera and that can be problematic if someone is maxing out the camera in other areas like FPS and then it stutters.

Further some cameras can handle H265 better than others, even if the camera "claims" to support it.

In theory it is supposed to need 30% less storage than H264, but most of us have found it isn't that much. My savings were less than few minutes per day. And to my eye and others that I showed clips to and just said do you like video 1 or video 2 better, everyone thought the H264 provided a better image.

The left image is H264, so all the blocks are the same size corresponding to the resolution of the camera. H265 takes areas that it doesn't think has motion and makes them into bigger blocks and in doing so lessens the resolution in those larger blocks yet increases the camera CPU demand to develop these larger blocks.

1667974399793.png



In theory H265 is supposed to need half the bitrate because of the macroblocking. But if there is a lot of motion in the image, then it becomes a pixelated mess. The only way to get around that is a higher bitrate. But if you need to run the same bitrate for H265 as you do H264, then the storage savings is essentially zero.


In my testing I have one camera that sees a parked car in front of my house. H265 sees that the car isn't moving, so it macroblocks the whole car and surrounding area. Then the car owner walked up to the car and got in and the motion is missed because of the macroblock being so large. Or if it catches it, because the bitrate is low, it is a pixelated mess during the critical capture point and by the time H265 adjusts to there is now motion, the ideal capture is missed.

In my case, the car is clear and defined in H264, but is blurry and soft edges in H265.

Digital zooming is never really good and not something we recommend, but you stand a better chance of some digital zoom with H264 rather than a large macroblocked H265. I can digital zoom on my overview camera and kinda make out the address number of the house across the street with H264, but not a chance with H265 as it macroblocked his whole house.

H265 is one of those theory things that sounds good, but reality use is much different.

Some people have a field of view or goals that allow H265 to be sufficient for their needs.

As always, YMMV.
 
You can also try to compare those h264h/h265 in General Encoding Strategy with AI Coding Encoding Strategy...

Ai Coding Strategy is giving nice compresion quality boost for moving humans / cars... Which allows to reduce bandwidth and have good quality human / cars images (things which is most important for forensic)..

And on modern cams with fresh firmware (5442-S3) is giving ability to run camera in ABR (Average Bitrate) mode - where You specify average and max bitrates + quality...

very handy in installations with many cams - allows to reduce even more average bandwidth / storage used by camera but not restricting it when camera need it (human/cars movement).

PS. AI Coding Strategy and ABR are a new technologies in Dahua cams. They are NOT a VBR (Variable Bitrate) or Smart Codec (h.264+/h.265+) - which were very BAD on any camera (both HIK & Dahua).. And SmartCodec is removed by Dahua from latest 5442-S3 firmwares...
 
Last edited:
What you said is close to correct, however H265 does not use macroblocks, it uses coding tree units. Unlike the fixed blocks of H264, H265 can get more granular in blocking off in multiple rectangles to try and code as efficiently as possible, as your second picture demonstrates and this would be another example. But as you said, how well this is done depends on the encoding hardware. I doubt the hardware on these cameras is able to handle the more complex encoding features, hardware encoding is much more limited than software encoding on a CPU and takes a lot longer before the hardware is good, and requires die space on the chipset that isn't deemed worth it.

I have a feeling that AV1 will probably supersede H265 eventually and it won't get much improvement with new hardware as they'd rather invest that die area to AV1, that codec is still not quite finalized enough to make it to security cameras. It is used by Netflix and Youtube, but phones/TVs/PCs from a couple years ago didn't have hardware encode, just AV1 decode.

That, and as Steve mentioned, AI coding is probably another thing that will become more standard. Still CBR, but where the bits are used in the picture are shifted around to focus on moving stuff and de prioritize static areas and background. That allows the bitrate to be lowered but maintain quality on the objects/people that we want to see.
BlogImage-AVC-HEVC-Example-1.jpg
 
That is why I put "macroblocking" in quotes because the average person can understand macroblocking easier than tree units, but thanks for further explanation as to why these cameras are inefficient with other codec.....
 
Salve a tutti c'è qualcuno Ke mi potrebbe aiutare il mio DVR appena lo accendo rimane cosi
 

Attachments

  • IMG_20250301_175349.jpg
    IMG_20250301_175349.jpg
    1,004.4 KB · Views: 0
I wondered what the best encoding setting would be for a Color 4K-T180, so this afternoon I took some screenshots of a zoomed in target (street speed sign)at various compression/bit rates. H.264H @ 14336 bit rate seemed to be the best choice for this camera. H.265 had noticeable artifacts.
Most importantly, can we have a image comparison with H.264H @ 1433? I bet you that 1/10th the bitrate gives you 90% of the quality. If storage or bandwidth has a realistic cost assigned to it, I think you'll find that 1433 (roughly) is an optimal bitrate.
 
Last edited:
Most importantly, can we have a image comparison with H.264H @ 1433? I bet you that 1/10th the bitrate gives you 90% of the quality. If storage or bandwidth a realistic cost assigned to it, I think you'll find that 1433 (roughly) is an optimal bitrate.


Low light and closer up moving faces will see a bigger difference than bright daytime.
Kinda depends on what you want. I like the best quality I can get and storage cost isnt a concern