cmisip
Posts: 100
Joined: Tue Aug 25, 2015 12:38 am

Decoding H264 packets and format_in->extradata contents

Sat Aug 11, 2018 6:19 am

I'm using avcodec to read packets from an h264 rtsp stream and I am trying to decode with the mmal h264 decoder. I could send packets but not receive any. I verified that the packets being sent are valid NAL packets with the leading 0x00000001 start code.
I formed format_in->extradata using avcodec's supplied sps and pps from the input stream.

So I decided to look at example_basic_2.c It would seem that the extradata that it reads from an h264 file includes both the sps, pps, AND an IDR frame. Is this supposed to be the way to form the extradata for the mmal h264 decoder?

Thanks,
Chris

cmisip
Posts: 100
Joined: Tue Aug 25, 2015 12:38 am

Re: Decoding H264 packets and format_in->extradata contents

Wed Aug 15, 2018 12:52 am

This has been solved. The answer at:

viewtopic.php?f=29&t=220224&p=1353021#p1353021

Thanks,
Chris

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Decoding H264 packets and format_in->extradata contents

Wed Aug 15, 2018 7:03 am

extradata shouldn't include an idr frame. It sounds like the parsing in example_basic is incorrect (and also explains why I keep on seeing an error of extradata being too big).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5944
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Decoding H264 packets and format_in->extradata contents

Fri Aug 31, 2018 2:41 pm

I've just had to look at example_basic_2 and extradata for other reasons.

It is just being totally naive in taking the first 512 bytes of the ES and splatting it in to the extradata in the expectation that it covers the headers.
Reality is that that will get trimmed down to 128 bytes at https://github.com/raspberrypi/userland ... pi.c#L1006

From my other conversation, there isn't a guarantee that the SPS/PPS will always be <128 bytes, so may need to be revised at some stage. (Maintaining backwards compatibility could be entertaining).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Advanced users”