Discussion:
[Live-devel] get H.264 frame width and height out of SPS
Roland Aigner
2017-03-23 13:28:25 UTC
Permalink
Hi,

I am trying to figure out how to get the frame width and height out of a H.264 stream and I'm having some difficulties understanding how to decode a SPS.

On the FAQ section on live555.com I found the following:

"If you are receiving H.264 video data, there is one more thing that you have to do before you start feeding frames to your decoder. H.264 streams have out-of-band configuration information ("SPS" and "PPS" NAL units) that you may need to feed to the decoder to initialize it. To get this information, call "MediaSubsession::fmtp_spropparametersets()" (on the video 'subsession' object). This will give you a (ASCII) character string. You can then pass this to "parseSPropParameterSets()" (defined in the file "include/H264VideoRTPSource.hh<http://www.live555.com/liveMedia/doxygen/html/H264VideoRTPSource_8hh.html>"), to generate binary NAL units for your decoder."

Unfortunately, I cannot figure out where to go from here. For example, I get the following SPS
Z2QAKKwrQDwBE/LgIgAAB9AAAdTBHjhlQA==,aO48sA==
which apparently contains two SPropRecord entries of 25 and 4 bytes length, respectively:
0x67 0x64 00 0x28 0xac 0x2b 0x40 0x3c 0x1 0x13 0xf2 0xe0 0x22 00 00 0x7 0xd0 00 0x1 0xd4 0xc1 0x1e 0x38 0x65 0x40
0x68 0xee 0x3c 0xb0

I found a few sites on the web, giving brief explanations but every one of them gets ma stuck at some point.

Given that I would expect this to be a quite common task, I wanted to ask if there are some helper classes/functions in live555 that already prase the SPS and give me what I want. Otherwise, I would appreciate pointing me to a helpful source.

Thanks!
Ross Finlayson
2017-03-23 15:45:06 UTC
Permalink
Post by Roland Aigner
Given that I would expect this to be a quite common task, I wanted to ask if there are some helper classes/functions in live555 that already prase the SPS and give me what I want.
No there aren't - because the “LIVE555 Streaming Media” software doesn’t do any video decoding (or encoding), and what you’re asking for is a H.264 decoder. Specifically, you want to decode the SPS NAL unit - the one that begins with 0x67 - to figure out the video width and height.

You can do this - but you’ll need to look in H.264 decoding software (e.g., “ffmpeg”) for the answer. Or you can look for the official ISO/IEC document that describes H.264:
ISO/IEC 14496-10


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
Roland Aigner
2017-03-23 16:45:29 UTC
Permalink
Okay, thanks. I thought the SPS would be related to SDP... But makes sense, I just recently realized it's encoded in a NAL unit.

-----Ursprüngliche Nachricht-----
Von: live-devel [mailto:live-devel-***@ns.live555.com] Im Auftrag von Ross Finlayson
Gesendet: Donnerstag, 23. März 2017 16:45
An: LIVE555 Streaming Media - development & use <live-***@ns.live555.com>
Betreff: Re: [Live-devel] get H.264 frame width and height out of SPS
Post by Roland Aigner
Given that I would expect this to be a quite common task, I wanted to ask if there are some helper classes/functions in live555 that already prase the SPS and give me what I want.
No there aren't - because the “LIVE555 Streaming Media” software doesn’t do any video decoding (or encoding), and what you’re asking for is a H.264 decoder. Specifically, you want to decode the SPS NAL unit - the one that begins with 0x67 - to figure out the video width and height.

You can do this - but you’ll need to look in H.264 decoding software (e.g., “ffmpeg”) for the answer. Or you can look for the official ISO/IEC document that describes H.264:
ISO/IEC 14496-10


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
Ross Finlayson
2017-03-24 05:00:59 UTC
Permalink
Post by Roland Aigner
Given that I would expect this to be a quite common task, I wanted to ask if there are some helper classes/functions in live555 that already prase the SPS and give me what I want.
No there aren’t
I realized just now that this isn’t totally correct.

We *do* have some H.264 (and H.265) parsing code in the file “liveMedia/H264or5VideoStreamFramer.cpp”. This is used to parse raw H.264 (and H.265) video byte streams - in particular, so that our servers know the proper frame rate for the video.

Note in particular the function “analyze_seq_parameter_set_data()”, which does some parsing of SPS NAL units. (It does this to look for timing information, not width/height, but you might still find it useful.)


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

Loading...