Live Smooth Streaming
* Please note that this is preliminary information and the Live Smooth Streaming support is in development *
Publishing Point
The streaming module is extended to act as a Publishing Point. A Publishing Point is simply a URL that accepts input streams from one or more software encoders. The encoders use HTTP POST to send the audio/video fragments to the webserver.
Create a Publishing Point
Creating a publishing point is as simple as creating a directory in your webserver's document root.
cd /var/www/ mkdir oceans.isml
Important note: Make sure that the webserver has write access to the directory. (IIS5: wwwroot properties => Security => Internet Guest Account => Tick Allow 'Read' and 'Write').
The publishing point's URL is ' http://localhost/oceans.isml/oceans.ism'
Publishing one video and audio stream
Your input can be anything that FFMPEG supports. We'll be using a file. If you want to mimic a live encoding you can add the '-re' switch (Read input at native frame rate, mainly used to simulate a grab device).
AUDIO_OPTIONS=-acodec libfaac -ac 2 -ab 64k VIDEO_OPTIONS=-vcodec libx264 -vpre veryfast -g 100 -keyint_min 50 ffmpeg -y -i oceans.mov $(AUDIO_OPTIONS) $(VIDEO_OPTIONS) -b 400k -s 848x400 http://localhost/oceans.isml/oceans.ism?stream_id=oceans-400k-64k.ismv
Publishing multiple bitrate video streams (Method 1)
AUDIO_OPTIONS=-acodec libfaac -ac 2 -ab 64k VIDEO_OPTIONS=-vcodec libx264 -vpre veryfast -g 100 -keyint_min 100 -sc_threshold 0 ffmpeg -y -i oceans.mov $(AUDIO_OPTIONS) $(VIDEO_OPTIONS) -b 400k -s 848x400 http://localhost/oceans.isml/oceans.ism?stream_id=oceans-400k-64k.ismv ffmpeg -y -i oceans.mov -an $(VIDEO_OPTIONS) -b 200k -s 608x288 http://localhost/oceans.isml/oceans.ism?stream_id=oceans-200k.ismv
To execute the ffmpeg commands in parallel you simply concatenate the commands as follows: '{ ffmpeg & ffmpeg & }'.
Example:
{ ffmpeg -y -i oceans.mov $(AUDIO_OPTIONS) $(VIDEO_OPTIONS) -b 400k -s 848x400 http://localhost/oceans.isml/oceans.ism?stream_id=oceans-400k-64k.ismv &
ffmpeg -y -i oceans.mov -an $(VIDEO_OPTIONS) -b 200k -s 608x288 http://localhost/oceans.isml/oceans.ism?stream_id=oceans-200k.ismv & }
Important note: The 'stream_id' *must* include the bitrates of all the streams. E.g. 'oceans-200k.ismv' has one stream at 200 kbits, 'oceans-400k-64k.ismv' has two streams, the first stream encoded at 400 kbits and the second at 64 kbits).
Publishing multiple bitrate video streams (Method 2)
Instead of spawning a new FFmpeg process for each bitrate, you can also add additional tracks by using the '-newvideo' option.
PUBPOINT=http://localhost/oceans.isml/oceans.ism?stream_id=oceans-200k-64k-400k.ismv
ffmpeg -y -i oceans.mov $(AUDIO_OPTIONS) \
$(VIDEO_OPTIONS) -b 200k -s 608x288 "$(PUBPOINT)" \
$(VIDEO_OPTIONS) -b 400k -s 848x400 -newvideo
Server Manifest file (.ism)
The server manifest file is updated when a new stream is received from an encoder.
Client Manifest file (.ismc)
The client manifest file is generated dynamically by the Publishing Point from its in-memory index. When the live encoding finishes, the live stream transforms into a VOD stream. Viewers currently watching the live stream will not be interrupted, but new viewers will see the stream as a VOD.
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/$1$2.$3sm$4/$2.ismc -f
RewriteRule ^(.*/)?(.*)\.([is])sm([l])?/[Mm]anifest$ $1$2.$3sm$4/$2.ismc [PT]
RewriteRule ^(.*/)?(.*)\.([is])sm([l])?/[Mm]anifest$ $1$2.$3sm$4/$2.ism?manifest=live [PT]
RewriteRule ^(.*/)?(.*)\.([is])sm([l])?/QualityLevels\(([0-9]+)\)/Fragments\((.*)=([0-9]+)\)(.*)$ $1$2.$3sm$4/$2.ism?bitrate=$5&$6=$7 [PT]
Fragment requests
Fragments requests by clients/players are looked up in the in-memory index.
TODO
- [Done] Add a 'Close Publishing Point / End Of Stream' message to notify the end of a live stream.
- [Done] When a live stream is closed, convert the live stream to a VOD stream. I.e. write the MFRA boxes and VOD client manifest file.
- Add a DVR window size (e.g. generate client manifests with only the last 30 minutes)
- Add archiving/rollover.
- [Done] Generate iPhone/iPad .m3u8 playlist
- [Done] Add support for Live streams and Live manifests to Flash 10.1 player.
Feedback
If you have any questions, thoughts or ideas on Smooth Streaming you can leave a message on our forum.
