wiki:Smooth-Streaming-Technical-Notes

Smooth Streaming Technical Notes

back


Smooth Streaming H264 Content

How to smooth stream a single bit rate H264 MP4 file?

We start with the simplest case by not having to encode anything again, we just use our existing encoded H264 videos and want to play them back using Smooth Streaming in the Open Video Player. This way you will get the goodness of Smooth Streaming: fast start, fast seeking and bandwidth throttling. As we only have one bit rate encoded video you will obviously not yet get dynamic bit rate switching.

Generating the manifest file

The manifest file holds all the information about the video file, its duration, the streams, the codec info, and a list of all the available chunks.

Let's start with an example manifest file for one H264 encoded video file:

<?xml version="1.0" encoding="utf-8"?>
<SmoothStreamingMedia MajorVersion="1" MinorVersion="0" Duration="1391998333">
  <StreamIndex Type="video" Subtype="H264" Chunks="47" Url="Fragments(video={start time})">
    <QualityLevel Bitrate="1450000" FourCC="H264" Width="640" Height="480" CodecPrivateData="0142400DFFE1000A6742001E96560501E88001000468CA8E20" />
    <c n="0" d="30000000" />
    <c n="1" d="30000000" />
    <c n="2" d="30000000" />
    <c n="3" d="30000000" />
    <c n="4" d="30000000" />
    <c n="5" d="30000000" />
    <c n="6" d="30000000" />
    <c n="7" d="30000000" />
    <c n="." d="30000000" />
    <c n="44" d="30000000" />
    <c n="45" d="30000000" />
    <c n="46" d="11666666" />
  </StreamIndex>
</SmoothStreamingMedia>

The time scale that Smooth Streaming uses is 10 * 1000 * 1000 ticks per seconds. So the given duration (1391998333) is 139.1998333 seconds, or about 2:19. The Subtype and FourCC are 'WVC1' for 'VC-1' encoded video and 'H264' for 'AVC' (H264) encoded video.

The Url in the StreamIndex is concatenated with the Play URL (minus the manifest file) to create the HTTP requests for the individual fragments.

The CodecPrivateData is a direct copy from the 'avc1' atom in the track's Sample Description. Just convert it from binary to printable hex.

A list of chunks follow each with a length of 3 seconds (except for the last chunk).

Determining the start and duration of a chunk

The chunks themselves are always self-contained and must not reference any frames from previous chunks. Therefore they must always start with a keyframe/IDR-frame and be encoded with a Closed GOP setting. A Closed GOP setting means that frames from the current GOP cannot reference I frames (full frames) from the previous GOP.

The sync samples table of the MP4 movie is used to calculate the start and durations of a chunk.

Generating a fragmented MP4 movie (moof)

Smooth Streaming uses the Fragmented MP4 file format for its chunks. Although the chunks are decodeable by themselves when you feed them (nearly) directly into a codec, they do not have the required 'moov' atom. Pretty much all video players won't be able to play these chunks by themselves.

Generating the chunks on the fly

Now here comes the tricky part which took me a long time to figure out. The data that Smooth Streaming expects is in Annex B (start codes 0x000001) format. Luckily this is an easy conversion, so we can do that on-the-fly.

Another thing to remember is that all the chunks need to start with a SPS (Sequence Parameter Set) and PPS (Picture Parameter Set) unit. These are duplicated from the CodecPrivateData field.

The trac run atom holds the duration and size for each sample/frame. Again we convert the duration to 100 nano-second units.

References

Next

Feedback

If you have any questions, thoughts or ideas on Smooth Streaming you can leave a message on our [topic:41 forum] or write us a private mail.

Last modified 13 years ago Last modified on 06/15/09 14:42:40