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

前端 未结 4 1169
我在风中等你
我在风中等你 2020-12-15 08:36

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:

相关标签:
4条回答
  • 2020-12-15 09:00

    As it turns out, the answer to my question is written in this document: ISO/IEC 14496-10:2005, under section 7.3.2.1. And to get it I need to pay. So... =)

    0 讨论(0)
  • 2020-12-15 09:07

    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 : http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/rtpdec__h264_8c-source.html#l00360

    0 讨论(0)
  • 2020-12-15 09:10

    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.

    0 讨论(0)
  • 2020-12-15 09:12

    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.

    0 讨论(0)
提交回复
热议问题