Use SimpleCDN for Silverlight streaming

Microsoft’s Smooth Streaming use standard http protocol, so it is possible to use simplecdn mirror bucket for delivering.

Here is my step by step to use open source software and simplecdn for HD video delivering.

Step 1: Server
Even though the Microsoft has opened spec for a while, there is current only 1 open source smooth streaming server

It has a few server plugins including apache and nginx. I choose nginx as my backend server. You can download the nginx plugin from It has two parts, a nginx module and a small utiility mp4split which converts mp4 files to fragmented format.

Nginx doesn’t use dynamic linked library, so you have to recompile the entire binary. I compiled the smooth streaming module on nginx-0.7.62 without any problem.

Step 2: Encoding
The entire process is documented on here. It require avisynth and a few other windows utilites.

If you need to do it on linux, here is how:
You will need both ffmpeg and x264. I have tried use ffmpeg alone, but it can not accept stats file from a different bit rate setting which is required step.

Direct pipe through ffmpeg and x264 also doesn’t work, because x264 can’t recognize file type, so you need a named pipe.

mkfifo video.y4m

This file can be reused many times.

Pass 1:

ffmpeg -i -an -f yuv4mpegpipe - > video.y4m & 
x264 --threads auto --profile high --level 3.2 --preset slow --no-mbtree --b-pyramid  --min-keyint 24 --keyint 96 --pass 1 --bitrate 2524 -o /tmp/bbb_2524.mp4 video.y4m

You can also run these two commands under 2 different console windows. Setting –no-mbtree is important.

Pass 2:
If everything go ok in pass 1, you can now run pass 2 for multiple bitrate

ffmpeg -i -an -s 256x144 -f yuv4mpegpipe - > video.y4m & 
x264 --threads auto --profile high --level 3.2 --preset slow --no-mbtree --b-pyramid  --min-keyint 24 --keyint 96 --pass 2 --bitrate 260 -o /tmp/bbb_260.mp4 video.y4m

Repeat this step with your desired resolution, bitrate and filenames.

The output mp4 file from x264 cannot be streamed, you will need a small utility qt-faststart to fix them.

Problem: I can’t encode playable audio file. If I include audio, the player simply stop.

Now following the rest step described here to split your mp4 files.

Step 3: Player
Unfortunately there’s no working open source player can do smooth stream. Code-shop’s website mentioned openvideoplayer can be updated by replaced with smoothstreaming dll, but I can not find where to put the file.

So I duplicated code-shop’s demo page.

Step 4: SimpleCDN
The simplest step, make a mirror bucket and point it to your webserver.


Here is my 720p video streaming through simplecdn.

No audio yet. It looks exactly like every other demo page, but it stream through my nginx server and simplecdn. Microsoft’s player use additional query parameters to speedup playback, but simplecdn will strip them away.

Other thought:
I think it is possible to split fragmented mp4 files to real files, so you probably need not a special server module.

  • Jason S. Clary

    Have you had any luck encoding SilverLight compatible h.264+aac mp4 files with ffmpeg? Not smooth streaming, just download and play. I’ve tried various presets and whatnot and although the files play fine in QT and VLC, SilverLight fails. Output from x264 and QT Pro plays fine, though.

    If you’ve gotten it to work, is there any chance you could share your parameters?

  • Jason S. Clary

    I figured out my problem. The biggest stumbling block was SilverLight seems to choke on multichannel audio. I used params from:

    but I added the all-important “-ac 2” param to convert multichannel to stereo and it works. Maybe it’ll help someone else.

  • Yejun

    @Jason S. Clary
    I have problem encoding multichannel audio as well.

  • Hi, we’re adding encoding for smooth streaming support to, would you like to be our beta tester for this feature?

    Thank you.

  • Pingback: links for 2011-08-31 « Donghai Ma()