NVENC HEVC encoding of 3840x2160 results in coded size of 3840x2176
We’re using the NVENC HEVC encoder of the NVIDIA Tesla M60 gpu (G3.8xlarge in AWS) to create a 4K HEVC 3840x2160 video stream (YUV420 8bit, Main profile, HQ preset, 50 FPS).
This results in a coded size of 3840x2176 (SPS contains pict_height_in_luma_samples of 2176) and a
conformance cropping window of 16 pixels (conf_win_bottom_offset = 8). So NVENC generates 16 lines extra lines at the bottom which need to be cropped off by the decoder.
The problem is that one of our customers has a decoder (IRD UHD HEVC) which doesn’t support more then 2160 coded lines. The customer says the NVENC HEVC video output is not following to the ETSI TS 101 154 V2.4.1 specification (table 21 on page 130) which only allows a maximum coded resolution of 3840x2160. ETSI TS 101 154 V2.4.1 can be found here: http://www.etsi.org/deliver/etsi_ts/101100_101199/101154/02.04.01_60/ts_101154v020401p.pdf
Our questions:
- It looks like the NVENC HEVC encoder by default outputs a coded height which is a multiple of 32 lines, is this true?
- Is there a setting/parameter in the NVENC API which can be used to change the coded height alignment? So it's results in a coded height of 2160 lines instead of 2176 lines? We've tried to play with minCUSize and maxCUSize properties of the NV_ENC_CONFIG_HEVC data structure but this doesn't seem to have influence on the coded height (pic_height_in_luma_samples in the output stream). The H.265 specification specifies that the pic_height_in_luma_samples shall be an integer multiple of MinCbSizeY, when minCUSize is set to 8x8, this will result in MinCbSizeY of 8, but still the pic_height_in_luma_samples stays a multiple of 32 (2176 in this case).
Here some additional information:
This situation can be easily reproduced by executing the following ffmpeg commandline:
ffmpeg -f lavfi -i smptebars=duration=5:size=3840x2160:rate=50 -c:v hevc_nvenc -s 3840x2160 ./hevc.ts
The height and coded_height can be checked with ffprobe:
ffprobe ./hevc.ts -show_streams | grep "height"
This results in:
height=2160
coded_height=2176
When analyzing the HEVC NAL units one can see that the Sequence Parameter Set contains pic_height_in_luma_samples of 2176 and conformance_window_flag of 1 and conf_win_bottom_offset of 8 (for yuv420 this value needs to be multiplied with 2, so results in 16 lines need to be cropped off the bottom).