Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode sprop-parameter-sets in a H264 SDP?

Tags:

base64

h.264

sdp

What is the meaning of Base64 decoded bytes in sprop-parameter-sets in SDP for a h264 stream? How can I know the video size from this example?

SDP example:

sprop-parameter-sets=Z0IAKeNQFAe2AtwEBAaQeJEV,aM48gA==

First part decoded from Base64 to Base16:

67 42 00 29 E3 50 14 07 B6 02 DC 04 04 06 90 78 91 15

Second part (comma separated):

68 CE 3C 80

ANSWER: Fetching the dimensions of a H264Video stream

like image 369
Cipi Avatar asked Mar 04 '10 10:03

Cipi


2 Answers

The spec you require is available for free download from the ITU website here:- H.264 (03/10)

Select the freely downloadable PDF and you'll find the format detailed in section 7.3.2.1.1.

Sorry, wasn't being obtuse with my previous answer, just didn't know that the information was available in the public domain.

like image 75
Jonathan Websdale Avatar answered Sep 18 '22 03:09

Jonathan Websdale


Of course the spec is always best, but the sprop-parameter-sets in the SDP generally consist of your sequence parameter and picture parameter sets, base-64 encoded and delimited by a comma. The sequence parameter and picture parameter sets basically tell the decoder how to properly decoding the incoming H264 stream; without it you cannot decode correctly.

Writing a parser for SPS/PPS isn't that hard, although to do this you will absolutely need the specification. You'll also need to have a good bit-reader class and knowledge of how exponential golomb encoding works for both signed and unsigned values. See here and here.

Lastly, the code found in this thread on Doom9 was invaluable to me--it's basically a full parser for an elementary H264 stream. It includes a bit reader class, routines to parse NALU, sps, pps, VUI parameters, sequence scaling matrices, etc. It's a pretty handy piece of code for any video engineer.

like image 34
kidjan Avatar answered Sep 20 '22 03:09

kidjan