English 中文(简体)
Flex: Multi bitrate switching between live streams using the VideoDisplay component
原标题:

I am passing to the source property of a VideoDisplay component a DynamicStreamingVideoSource object with 3 different dynamic live stream items, described by this XML, for your consideration:

src="rtmp://88.87.56.214:1935/live/fashiontv_tmo_h.stream" bitrate="19200" src="rtmp://88.87.56.214:1935/live/fashiontv_tmo_m.stream" bitrate="9000" src="rtmp://88.87.56.214:1935/live/fashiontv_tmo_l.stream" bitrate="3600"

But the player then runs the stream with the lowest bitrate, out of those 3. Wasn t it supposed to go for the stream with the highest bitrate, that is viewable by the end-user? All 3 streams have been individually tested and they are all viewable.

Thanks, Liviu

问题回答

I fixed it!!!

I know this reply is 5.5 years later, but this could still help someone. I had the same problem and was able to fix it after hours and hours of searching for an answer. All you need is to have a non-zero value for the buffer in the media player.

Examples:

Using Spark VideoDisplay:

<s:VideoDisplay id="rtmpABRVideo" width="320" height="240" initialize="rtmpABRVideo.mx_internal::videoPlayer.bufferTime=2">
  <s:DynamicStreamingVideoSource host="rtmp://localhost:1935/live" streamType="live">
    <s:DynamicStreamingVideoItem streamName="webcam_1000" bitrate="1000" />
    <s:DynamicStreamingVideoItem streamName="webcam_500" bitrate="500" />
    <s:DynamicStreamingVideoItem streamName="webcam_150" bitrate="150" />
  </s:DynamicStreamingVideoSource> 
</s:VideoDisplay>

Using OSMF Components:

var dynResource:DynamicStreamingResource = new DynamicStreamingResource( rtmp://localhost/live );
dynResource.urlIncludesFMSApplicationInstance = false;
dynResource.streamItems = Vector.<DynamicStreamingItem>([
                                new DynamicStreamingItem("mp4:webcam_150", 150, 320, 240),
                                new DynamicStreamingItem("mp4:webcam_500", 500, 320, 240),
                                new DynamicStreamingItem("mp4:webcam_1000", 1000, 320, 240)
                          ]);

var videoElement:VideoElement = new VideoElement();
videoElement.resource = dynResource;

var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
mediaPlayerSprite.width = 320;
mediaPlayerSprite.height = 240;
mediaPlayerSprite.media = videoElement;
mediaPlayerSprite.mediaPlayer.bufferTime = 2;

addChild(mediaPlayerSprite);

Hope this was helpful for someone out there!

I was pretty sure the VideoDisplay component will display whatever source URL you send it. Without seeing code, I m not sure what is going on.

If you want to display a different bitrate stream you ll have to tell the VideoDisplay component to switch the URL. If you want to do some automatic bitrate switching "on the fly" I believe that has to be done at the server, not the client.

I have posted a post on my blog with some source code that is very easy to understand a while back.

check it out here





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签