How do you create IIS Smooth streaming files using h.264 with the SDK?

Answered How do you create IIS Smooth streaming files using h.264 with the SDK?

  • Tuesday, December 15, 2009 9:51 PM
     
     
    Can anybody post a code sample on how to create a Silverlight smooth streaming project that is encoded with h264 using the SDK?

All Replies

  • Tuesday, December 15, 2009 10:16 PM
    Moderator
     
     Proposed Answer
    Pseudo C# code (didn't try to compile it, but it should start you up):


    Job job = new Job();
    MediaItem mediaItem = new MediaItem(inputFile);
    job.MediaItems.Add(mediaItem);

    VideoProfile videoProfile = new MainH264VideoProfile();
    videoProfile.SmoothStreaming = true;
    videoProfile.SeparateFilesPerStream = true; // or false if you want all streams in one file

    // Add your streams here via VideoProfile.Streams
    // Note: The default videoprofile up there has already one, so you might have to delete it first before populating the ones you want.

    mediaItem.OutputFormat = new MP4OutputFormat()
    {
        VideoProfile = videoProfile,
        AudioProfile = new AacAudioProfile(128, 2, 44100, 16)
    };

    job.Encode();



    The only special thing to remember is to set VideoProfile.SmoothStreaming to true. The rest is standard H.264 profile stuff.


  • Wednesday, December 16, 2009 10:53 PM
     
     Answered
    Thanks, below is the code that I got working:

                    //create video profile for output files
                    MainH264VideoProfile videoProfile = new MainH264VideoProfile();

                    //remove default stream
                    videoProfile.Streams.RemoveAt(0);
                    videoProfile.SeparateFilesPerStream = true;

                    //add bitrate outputs for any default setting that is lower than original
                    foreach (EncoderSettings setting in GetSettingsList())
                    {
                        videoProfile.Streams.Add(new ConstantBitrate(setting.AvgBitRate, false), new Size(setting.Width, setting.Height));
                    }

                    // Use smooth streaming with automatically sized streams.
                    videoProfile.SmoothStreaming = true;

                    //assign profile to media item for encoding
                    mediaItem.OutputFormat = new MP4OutputFormat();
                    mediaItem.OutputFormat.VideoProfile = videoProfile;
                    mediaItem.OutputFormat.AudioProfile = new AacAudioProfile(128, 2, 44100, 16);

                    job.MediaItems.Add(mediaItem);
    • Marked As Answer by millr Wednesday, December 16, 2009 10:53 PM
    •  
  • Wednesday, December 16, 2009 11:44 PM
    Moderator
     
     
    As you found out already, H.264 VBR SmoothStreaming isn't supported. I'm sorry I didn't warn you. :)