WebRTC - receiving H264 key frames

736 views Asked by At

I've been playing with WebRTC using libdatachannel, experimenting and learning.

Wrote some code to parse RTP packets into NALU's, and testing connecting to a "known good" server which sends H264 video.

Problem:

I'm only seeing NALU's with type = 1 (fragmented into multiple FU-A's) and sometimes type = 24 (which contain embedded SPS and PPS NALU's).

So I don't understand how to decode / render this stream - I would expect the server to send a NALU with a key frame (NALU type 5) automatically to a newly connected client, but it does not.

What am I missing to be able to decode the stream? What should I do to receive a key frame quickly? If my understanding is correct, I need a key frame to start decoding / rendering.

Tried requesting a key frame from code - it does arrive (type 5) but after some delay which is undesirable.

And yet the stream plays perfectly fine with a web browser client (Chrome, JavaScript) and starts up quickly.

Am I maybe overthinking this, and the browser also has a delay but I'm just perceiving it as instant?

In any case, what's the situation with key frames? Is a client supposed to request them (and without that, a server should not be expected to send them)?

If so what's a good interval? One second, two, three?

0

There are 0 answers