views:

16

answers:

1

has anyone used microsoft expression encoder SDK to do server side encoding of videos to preapare it for silverlight adaptive streaming?

What is your experience with it?

A: 

I made a windows service for encoding movie files to create Adaptive Streaming files on the fly once uploaded. The downside for me was that I wanted to store the adapative stream files inside a database. The only option to achieve this was to create your own WIN32 File API or some sort of WebDav system which can return the filestreams. You can't create your own extention of SmoothStreamHandler to get your filestream other ways (like from database or whatever).

Beware that it eats up all CPU's you have in your system, so dont run this on your webserver but have a seperate server for it. Also the server doesn't have to have much memory as it doesn't have a 64-bit version so it cant use more as 3,2gb. Just CPU power and some fast disks would be best.

There are also hardware solutions which support Silverlight Adaptive Streaming, like Elemental Server.

The SDK itself is rather easy to use:

Sample:

private void ProcessFile(string filename, string outputFolder)
{
    try
    {
        MediaItem mediaItem;

        AdvancedVC1VideoProfile videoProfile = new AdvancedVC1VideoProfile();
        videoProfile.SmoothStreaming = true;
        videoProfile.AdaptiveGop = false;
        videoProfile.Streams.RemoveAt(0);

        try
        {
            mediaItem = new MediaItem(filename);

            // Add streams
            videoProfile.Streams.Add(new ConstantBitrate(1450), new Size(848, 480));
            videoProfile.Streams.Add(new ConstantBitrate(1050), new Size(592, 336));
            videoProfile.Streams.Add(new ConstantBitrate(600), new Size(424, 240));

            mediaItem.OutputFormat.VideoProfile = videoProfile;
        }
        catch (InvalidMediaFileException ex)
        {
            Console.WriteLine(ex.Message);
            return;
        }

        using (Job job = new Job())
        {
            job.MediaItems.Add(mediaItem);
            job.OutputDirectory = outputFolder;
            job.CreateSubfolder = false;

            job.EncodeProgress += (object sender, EncodeProgressEventArgs e) =>
            {
                // Trace progress..
            };

            job.Encode();

        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        return;
    }
}
Peter Kiers