[Libav-user] how to obtain sps and pps

Alex Cohn alexcohn at netvision.net.il
Wed Nov 16 08:42:47 CET 2011

On Wed, Nov 16, 2011 at 02:43, Yingzhou Zhang <zhangjsj at gmail.com> wrote:
> Hey guys,here is one simple question: how do I obtain sps and pps from H264
> stream(over RTP).I know through header & 0x1f==7 || header & 0x1f ==8 to
> determine them,but what about their length?

As any other NAL unit, the size is either part of its header, or
should be determined from the bitstream.

> Plus how to use them to "init" decoder?

You are supposed to send these two NAL units with the first I-frame
(just before its first data NAL), which normally is simply the first
frame you send to the decoder. In principle, any I-frame may have
these two to change the stream settings on the fly.

> I have been googled around,got a little confused,thanks for your help and
> some code example would be appreciated!!

> Cheers....
> ---------------------
> Best Regards

Good luck,
Alex Cohn

More information about the Libav-user mailing list