Adaptive streaming 3 first seconds blury

Aug 31, 2011 at 5:38 PM

Hello,

I tried to get better quality at start but I couldn't figure how.

I tried to use

public MainPage() {
            InitializeComponent();
            player.MediaPluginRegistered += new EventHandler<CustomEventArgs<IMediaPlugin>>(player_MediaPluginRegistered);
            player.MediaOpened += new EventHandler(player_MediaOpened);
        }

        void player_MediaOpened(object sender, EventArgs e) {
            var maximumPossibleBitrate = player.AvailableVideoBitrates.Max();
            _adaptivePlugin.SetVideoBitrateRange(maximumPossibleBitrate, maximumPossibleBitrate, true);
        }

        IAdaptiveMediaPlugin _adaptivePlugin = null;

        void player_MediaPluginRegistered(object sender, CustomEventArgs<IMediaPlugin> e) {
            var adaptivePlugin = e.Value as IAdaptiveMediaPlugin;
            if (adaptivePlugin == null) return; 
            if (_adaptivePlugin == null) _adaptivePlugin = adaptivePlugin;
        }
but it doesn't work the 3 first second are stile low quality.
how can I setup the player in the way it use a middle quality track instead of the lowest one and after the 3 first second it ramps up or down to the best bit rate for the user.

Can any one help?
Thank you
Coordinator
Sep 3, 2011 at 5:12 PM

You can accomplish this by overriding OnManifestReady in SMFPlayer and calling something like:




         if (ActiveAdaptiveMediaPlugin != null) 
         {
                var videoStream = ActiveAdaptiveMediaPlugin.CurrentSegment.SelectedStreams.Where(i => i.Type == StreamType.Video).FirstOrDefault();

                if (videoStream != null)
                {
                        var track = videoStream.AvailableTracks.Where(**criteria**).FirstOrDefault();
                        if (track != null)
                        {
                            isStartupHeuristicsActive = true;
                            videoStream.SetSelectedTracks(new[] { track });
                        }
                }
         }

Then, when playback begins, open it up again.

        private void Player_PlayStateChanged(object sender, CustomEventArgs<MediaPluginState> e)
        {
            if (isStartupHeuristicsActive && e.Value == MediaPluginState.Playing)
            {
                isStartupHeuristicsActive = false;
                if (ActiveAdaptiveMediaPlugin != null)
                {
                    var videoStream = ActiveAdaptiveMediaPlugin.CurrentSegment.SelectedStreams.Where(i => i.Type == StreamType.Video).FirstOrDefault();
                    if (videoStream != null)
                    {
                        videoStream.SetSelectedTracks(videoStream.AvailableTracks);
                    }
                }
            }
        }

 

Sep 5, 2011 at 12:29 PM

Thank you Tim it works like a charm, the video is now very good on start :)

I updated the questions I started on stackoverflow as well http://stackoverflow.com/questions/7189741/iis-smooth-streaming-low-quality-on-start