<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">The encoder unfortunately only supplies frames in Annex B byte stream format requiring the frames to be parsed.</div></blockquote><div><br class=""></div>Are you sure about this? (Often, hardware encoders have firmware upgrades available.)</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""> Previously I was using my own class to identify the NAL unit's in conjunction with the H264VideoDiscreteFramer which worked fine but it's heavy on the CPU. So I've been trying to use the H264VideoFramer and just pass the full frames in which works ok and is faster than my solution except that I'm seeing a lot of truncated frames.<br class=""><br class="">Having looked into the code it appears to be caused by the behaviour of the StreamParser class; specifically the ensureValidBytes1() method which calls getNextFrame() on my source with maxSize = BANK_SIZE - fTotNumValidBytes. The method switches banks to ensure that the larger of numBytesNeeded or the input sources maxFrameSize() will fit.<br class=""><br class="">I can 'fix' the problem by increasing BANK_SIZE and implementing maxFrameSize() on my source but I'm not totally happy with this solution because I would prefer not to modify the library source and I'm just guessing for the maxFrameSize() value.<br class=""><br class="">I was wondering whether it's possible to return a partial frame from my video source?</div></blockquote><div><br class=""></div>Yes, but not in the way that you might think :-) A H.264 encoder actually delivers “NAL units”. “NAL units” are what actually get parsed by our code, and packed into RTP packets.</div><div><br class=""></div><div>Often, a “NAL unit” is a complete frame. It is possible, however, for a ‘key frame’ to be split up - by your encoder - into multiple ‘slice’ NAL units. For datagram streaming (e.g., over RTP), it is *much* better to have your key frames broken up into multiple ‘slice’ NAL units, than to have the key frame be a single, large NAL unit - which is what you have now. This is especially true if your key frames are exceptionally large: ~150000 bytes or larger, which appears to be the case for you, because you are hitting the BANK_SIZE limit (which was deliberately set to be larger than realistically needed).</div><div><br class=""></div><div>Note that a 150000 byte key frame NAL unit will get transmitted as more than 1000 RTP packets (datagrams). (Our code automatically handles the required fragmentation.) If *any* of these 1000 packets gets lost in transit, then the entire key frame will be undeliverable.</div><div><br class=""></div><div>If, instead, your encoder delivers each key frame as multiple ‘slice’ NAL units, then your streaming will be much more resilient to network packet loss.</div><div><br class=""></div><div>So, your first task should be to check whether your encoder:</div><div>1/ can be reconfigured to deliver discrete frames, rather than a stream with each NAL unit prepended by a 0x00 0x00 0x00 0x01 ‘start code’, and</div><div>2/ can be reconfigured to deliver key frames as multiple ‘slice’ NAL units, rather than as a single (ridiculously large) NAL unit.</div><br class=""><br class=""><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Ross Finlayson<br class="">Live Networks, Inc.<br class=""><a href="http://www.live555.com/" class="">http://www.live555.com/</a></span></span>
</div>
<br class=""></body></html>