<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div>We've been using live555MediaServer with MPEG-2 A/V in TS files successfully for quite some time now, but we are now experimenting with H.264 in TS. We've been unable to create files that stream as smoothly as our old MPEG-2 files.<br></div></blockquote><div><br></div>Our code has trouble streaming MPEG Transport Stream files that are extremely VBR (variable bit rate), which is what I suspect your file is. The problem is the "MPEG2TransportStreamFramer" class. This class uses the stream's PCR timestamps to compute (estimate) the duration of each of the (188-byte) Transport Stream 'packet' that pass through it, before they get packed into larger RTP packets and transmitted. These packet durations determine the rate at which the RTP packets get sent. Unfortunately, it's difficult to compute accurate duration estimates for VBR streams; consequently, the estimated duration sometimes gets too large, which means that some packets get delivered too slowly for the receiver (i.e., underflow). Alternatively, the estimated duration sometimes gets too small, which means that some packets will get delivered too quickly for the receiver (overflow, or even packet loss). The basic problem is that the "MPEG2TransportStreamFramer" class doesn't 'read ahead' through the incoming Transport Stream data, so it doesn't have any 'future' PCR timestamps to work from as it computes estimated durations; instead, it can work only from PCR timestamps that it has already seen.</div><div><br></div><div>One way to overcome problems streaming VBR files is to reencode them so that they're 'less VBR'. Unfortunately, this will likely increase the file's size, and thus the stream's bitrate.</div><div><br></div><div>Another possibility is to tweak (e.g., using compile-line definitions) some of the four constants</div><div><span class="Apple-tab-span" style="white-space:pre"> NEW_DURATION_WEIGHT</span></div><div><span class="Apple-tab-span" style="white-space:pre"> TIME_ADJUSTMENT_FACTOR</span></div><div><span class="Apple-tab-span" style="white-space:pre"> MAX_PLAYOUT_BUFFER_DURATION</span></div><div><span class="Apple-tab-span" style="white-space:pre"> PCR_PERIOD_VARIATION_RATIO</span></div><div>to try to get better performance. Unfortunately, this is somewhat of a 'black art', and there's no guarantee that this will improve things.</div><div><br></div><div>Down the road, a better solution might be to provide an alternative implementation of the "MPEG2TransportStreamFramer" class that 'reads ahead' (i.e., buffers some input transport data), so that it can look one PCR timestamp ahead, thereby producing more accurate duration estimates. The disadvantage of this, however, is that it would be less efficient than the current "MPEG2TransportStreamFramer" implementation (which doesn't buffer any input data at all).</div><div><br></div><div>Another possibility would be store packet durations in the 'index file' (that gets used when performing 'trick play' operations on Transport Stream files. The disadvantage of this, however, is that it would work only for prerecorded files, not 'live' input streams (e.g., from an encoder). It would also require an incompatible change to the index file format.</div><br><br><div apple-content-edited="true">
<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; font-size: medium; "><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; font-size: medium; ">Ross Finlayson<br>Live Networks, Inc.<br><a href="http://www.live555.com/">http://www.live555.com/</a></span></span>
</div>
<br></body></html>