IIS在启动平滑流低质量 [英] IIS Smooth streaming low quality on start

查看:135
本文介绍了IIS在启动平滑流低质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米托管在Windows Azure上一些自适应流媒体视频,我已经注意到,在开始视频开始与最低缴费比特率。这是一个大问题。

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.

我通过搜索,一个技巧可以通过挂钩manifestready事件和删除最低的比特率,然后加入他们一段时间后回做互联网看到。
这道理,但我已经看到了这样做的没有样品code。

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.

我从EX pression EN codeR 4播放器code和一看却无处发现在哪里做的改变。

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?

非常感谢你。

推荐答案

您好:我张贴的问题向媒体平台播放器的论坛,得到的作品。

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

的讨论是在这里: HTTP://smf.$c$cplex.com/discussions/271042

下面是code我使用:

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);
            }
        }
    }
}

感谢您

这篇关于IIS在启动平滑流低质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆