Get NALU length instead of Annex B start sequence

Is there any way of getting the output bitstream to have NALU lengths instead of the Annex B start sequence:


Thanks in advance

Hi jameshartt,

Could you elaborate a bit on your use-case?

Ryan Park

Hi Ryan,

Our use case is such that we can step through each NALU using the lengths. For streaming in general, but more specifically coding those NALUs such we can achieve better application level error correction suited to our needs.

Knowing the length of the NALUs would help us a great deal and allow us not to carry out that work either on the CPU or GPU.

Is this enough of an elaboration? I’m currently on holiday and will be back on Monday to elaborate further.



Mpeg4 stream format (where each NAL is prefixed by 4 bytes or 2 bytes field specifying this NAL size) is not easy to support in real-time encoding.
An encoder has to keep the nal-length field pointer and update it after the whole frame/slice processing finished. Consequently, data transmission is delayed to the end of frame/slice processing.

Thanks for the reply sriabtsev! We figured as much, we were just wondering if we were missing something in the SDK.

We’ll have to adapt in other ways, thanks very much!


Sorry for the late reply,

The NVENCODEAPI outputs slice sizes and slice offsets in NV_ENC_LOCK_BITSTREAM. Will that would be of any help to you? We support multiple slice modes which can be controlled through NV_ENC_PIC_PARAMS_: sliceMode, you can choose one depending on your use-case and also can get the slice offsets accordingly.

Ryan Park