[Live-devel] H.264 Details

Jerry Johns Jerry.Johns at nuvation.com
Tue Jun 24 13:06:18 PDT 2008


Since there seems to be quite a few ppl writing H.264 frame subclasses,
I think i'll give a gist of what I learned when i was creating one;

Basically, my stream was 0x00 00 00 01 delimited single NAL unit
entities - the first NAL was my SPS, then PPS and then picture slices
after that.

In your framer, after the delimiter, you read 1 byte, which is contains
basic info about the NAL unit - once you have this byte, you parse it:

 

NAL_nri = (readChar >> 5) & 0x3;

NAL_type = readChar & 0x1F;

NAL_forbidden = readChar & 0x80;          

 

Now, if your NAL unit size is less than ethernet MTU (~1400 bytes), then
you can go ahead and do single-NAL unit mode in which case you drop the
4 byte delimiter, and pass this to liveMedia to send

 

If it is > 1400 byte (most of the time they are), then you'll have to do
FU-A mode; FU-A mode specially requires an indicator and a header.

 

FU_indicator = (NAL_forbidden << 7) | (NAL_nri << 5) | (28); //28 is
FU-A type

FU_header = (NAL_type) | (FUA_START);  //FUA_START is 1<<7

 

This indicator goes first, then the header, and then you append your NAL
unit data - NOTE however, that the NAL unit data you append should not
have the delimiter AND the 1 byte NAL info present.

 

After this first transmission, you send successive FU-A packets with the
remaining NAL unit data with the same FU_indicator, but a changed
FU_header

if the current packet you're sending is not the last packet, then:

 

FU_header = (NAL_type);           //dont signal the end yet, as per RFC
Spec                                  

 

if it is the last packet then:

 

FU_header = (NAL_type) | (FUA_END); //signal last frame of NAL unit,
FUA_END = 1<<6

 

That's as easy as it gets to sending H.264 data to VLC and it should
play it beautifully :)

 

 

Jerry Johns

Design Engineer

Nuvation Research Corp - Canada

Tel: (519) 746-2304 ext. 225

www.nuvation.com <http://www.nuvation.com> 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20080624/360e6785/attachment-0001.html>


More information about the live-devel mailing list