[ACCEPTED]-How to decode sprop-parameter-sets in a H264 SDP?-sdp
The spec you require is available for free 6 download from the ITU website here:- H.264 (03/10)
Select 5 the freely downloadable PDF and you'll find 4 the format detailed in section 7.3.2.1.1.
Sorry, wasn't 3 being obtuse with my previous answer, just 2 didn't know that the information was available 1 in the public domain.
Of course the spec is always best, but the 20 sprop-parameter-sets in the SDP generally 19 consist of your sequence parameter and picture 18 parameter sets, base-64 encoded and delimited 17 by a comma. The sequence parameter and 16 picture parameter sets basically tell the 15 decoder how to properly decoding the incoming 14 H264 stream; without it you cannot decode 13 correctly.
Writing a parser for SPS/PPS isn't 12 that hard, although to do this you will 11 absolutely need the specification. You'll 10 also need to have a good bit-reader class 9 and knowledge of how exponential golomb 8 encoding works for both signed and unsigned 7 values. See here and here.
Lastly, the code found 6 in this thread on Doom9 was invaluable to me--it's 5 basically a full parser for an elementary 4 H264 stream. It includes a bit reader class, routines 3 to parse NALU, sps, pps, VUI parameters, sequence 2 scaling matrices, etc. It's a pretty handy 1 piece of code for any video engineer.
As it turns out, the answer to my question 2 is written in this document: ISO/IEC 14496-10:2005, under section 1 7.3.2.1. And to get it I need to pay. So... =)
The video size is in the "framesize" line of SDP, isn't it ?
00028 int av_strstart(const char *str, const char *pfx, const char **ptr)
00029 {
00030 while (*pfx && *pfx == *str) {
00031 pfx++;
00032 str++;
00033 }
00034 if (!*pfx && ptr)
00035 *ptr = str;
00036 return !*pfx;
00037 }
00038
p is a pointer of your line SDP
if (av_strstart(p, "framesize:", &p)) {
00370 char buf1[50];
00371 char *dst = buf1;
00372
00373 // remove the protocol identifier..
00374 while (*p && *p == ' ') p++; // strip spaces.
00375 while (*p && *p != ' ') p++; // eat protocol identifier
00376 while (*p && *p == ' ') p++; // strip trailing spaces.
00377 while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1) {
00378 *dst++ = *p++;
00379 }
00380 *dst = '\0';
00381
00382 // a='framesize:96 320-240'
00383 // set our parameters..
00384 codec->width = atoi(buf1);
00385 codec->height = atoi(p + 1); // skip the -
00386 codec->pix_fmt = PIX_FMT_YUV420P;
}
reference 1 : http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/rtpdec__h264_8c-source.html#l00360
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.