silverlightsilverlight-4.0azuresmooth-streaming-player

IIS Smooth streaming low quality on start


I m hosting some adaptive streaming video on windows azure and I have noticed that at the beginning the video start with the lowest avaiable bitrate. That is a big issue.

I have seen by searching the internet that a trick can be done by hooking the manifestready event and removing the lowest bitrates and then adding them back after some time. It make sense but I have seen no sample code of doing that.

I got the player code from expression encoder 4 and had a look but found nowhere where to do the change.

Does someone have more info on improving startup for smooth streaming?

Thank you very much


Solution

  • Hello I posted the question to the Media Platform Player forum and got an answer that works.

    The discussion is here: http://smf.codeplex.com/discussions/271042

    Here is the code I use:

    public MainPage() {
            InitializeComponent();
            player.MediaPluginRegistered += new EventHandler<CustomEventArgs<IMediaPlugin>>(player_MediaPluginRegistered);
            player.PlayStateChanged += new EventHandler<CustomEventArgs<MediaPluginState>>(Player_PlayStateChanged);
        }
    private IAdaptiveMediaPlugin _adaptivePlugin = null;
    private bool isStartupHeuristicsActive = false;
    
    void player_MediaPluginRegistered(object sender, CustomEventArgs<IMediaPlugin> e) {
        var adaptivePlugin = e.Value as IAdaptiveMediaPlugin;
        if (adaptivePlugin == null) return; 
        if (_adaptivePlugin == null) _adaptivePlugin = adaptivePlugin;
        _adaptivePlugin.ManifestReady +=new Action<IAdaptiveMediaPlugin>(_adaptivePlugin_ManifestReady);
    }
    
    void  _adaptivePlugin_ManifestReady(IAdaptiveMediaPlugin obj)
    {
        if (_adaptivePlugin != null)
        {
            var videoStream = _adaptivePlugin.CurrentSegment.SelectedStreams.Where(i => i.Type == StreamType.Video).FirstOrDefault();
    
            if (videoStream != null)
            {
                var averageBitrate = videoStream.AvailableTracks.Average(t => t.Bitrate);
    
                var track = videoStream.AvailableTracks.FirstOrDefault(t => t.Bitrate >= averageBitrate);
                if (track != null)
                {
                    isStartupHeuristicsActive = true;
                    videoStream.SetSelectedTracks(new[] { track });
                }
            }
        }
    }
    
    private void Player_PlayStateChanged(object sender, CustomEventArgs<MediaPluginState> e)
    {
        if (isStartupHeuristicsActive && e.Value == MediaPluginState.Playing)
        {
            isStartupHeuristicsActive = false;
            if (_adaptivePlugin != null)
            {
                var videoStream = _adaptivePlugin.CurrentSegment.SelectedStreams.Where(i => i.Type == StreamType.Video).FirstOrDefault();
                if (videoStream != null)
                {
                    videoStream.SetSelectedTracks(videoStream.AvailableTracks);
                }
            }
        }
    }
    

    Thank you