9 Replies Latest reply on Aug 12, 2010 7:55 PM by charles_newman-SZDpEK

    Dynamic Streams always starting with the lowest bitrate ?

    Philarmon

      Hi,

       

      I suppose that is something small that i am missing but this is just driving me nuts

       

      If i start to play a dynamic stream (Akamai) the player always starts with the lowest quality and then switch up after a while. However, in the akamai player for example, the stream starts with a great quality straight away and then still adjust the quality if needed.

       

      So what is the proper way to set an acceptable quality right from the start ?

       

      I am using just the SMIL plugin, without the Akamai plugin. Is it worth to use it as well to optimize this issue ?

       

      Thank you for your time !

        • 1. Re: Dynamic Streams always starting with the lowest bitrate ?
          charles_newman-SZDpEK

          Hi,

           

          OVP uses a shared object to store the average max bitrate last used.  You could do the same in your player or use some arbitrary selection method such as "use the index with the highest bitrate less than or equal to 600kbps".

           

          To do this in OSMF you need to set the initialIndex property on the DynamicStreamingResource for the MediaElement.

           

          The Akamai plugin for OSMF doesn't select a starting index for dynamic streaming so using that plugin won't help you in this case. That logic probably belongs at the player level anyway.

           

          Since you are using the SMIL plugin, you are probably calling createMediaElement on a MediaFactory and therefore this may not be trivial since you'll have to get to the DynamicStreamingResource before the NetStreamPlayTrait calls the NetStream.play2() method.

           

          Can you file a bug on this?  Specifically about making this easier to do using the SMIL plugin, perhaps using resource metadata.

           

          Thanks,

          - charles

          1 person found this helpful
          • 2. Re: Dynamic Streams always starting with the lowest bitrate ?
            Philarmon Level 1

            Charles, thanks for your help. However, i still don't understand how this is supposed to work.

             

            Yes, i am using the createMediaElement()with the MediaFactory. I am passing a .smil url as the host so i have no idea how many streams are in there. And i am only getting the total number of streams and any other stream information after the stream starts playing (when i am getting the DynamicStreamTrait).

             

            So how i am supposed to set the initialIndex before the stream plays ?

            • 3. Re: Dynamic Streams always starting with the lowest bitrate ?
              charles_newman-SZDpEK Level 1

              I think you have a few options:

               

              You could modify the SMIL plugin to take a resource metadata value specifying the start index and change the logic that creates the DynamicStreamingResource to use this value to set the initialIndex. Then file a bug for us to make this change or a better one to make this easy for people to do this using the SMIL plugin.

               

              Or you could write your own SMIL parser and create the DynamicStreamingResource object yourself. Inspecting the bitrates in the object and choosing a starting index either based on the avg max bitrate you've saved in a shared object or some other bitrate selection process. Parsing the SMIL for FMS MBR should be trivial. There is a very simple parser in OVP you could take a look at.

               

              - charles

              • 4. Re: Dynamic Streams always starting with the lowest bitrate ?
                Andrian Cucu Adobe Employee

                Hi,

                 

                Here a description of the workflow that we used for making the player start with higher initial index(based on the measured bandwidth) in StrobeMediaPlayer.

                 

                1. Initially we disable automatic switching (otherwise you cannot change the starting index manually):

                 

                addEventListener(MediaPlayerCapabilityChangeEvent.IS_DYNAMIC_STREAM_CHANGE, onIsDynamicStreamChange);

                private function onIsDynamicStreamChange(event:Event):void

                {

                if (isDynamicStream)

                {

                     this.autoDynamicStreamSwitch = false;

                }

                }

                 

                2. In our NetLoader we override the createNetStreamSwitchManager method and the set the initial index based on the badwidth measurements we stored in LSO:

                 

                override protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase

                {

                     ...

                     dsResource.initialIndex = initialIndex;

                     ...

                }

                 

                3. In the end we turn automatic switching back to true:

                 

                addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onMediaPlayerStateChange);

                private function onMediaPlayerStateChange(event:MediaPlayerStateChangeEvent):void

                {

                if (event.state == MediaPlayerState.PLAYING)

                {

                if (isDynamicStream && autoDynamicStreamSwitch != autoSwitchQuality)

                {

                autoDynamicStreamSwitch = autoSwitchQuality;

                }

                }

                }

                 

                 

                For doing this in a plugin you'll need to use the DynamicStreamTrait (you can set the autoSwitch property to true/false from your plugin.

                 

                Here are some links that I hope will be helpful to you:

                 

                1. See the StrobeMediaPlayback in action here:

                http://osmf.org/smptest/debug.html?plugin_smil=SMILPlugin.swf&src=http://mediapm.edgesuite .net/osmf/content/test/smil/elephants_dream.smil

                 

                (observe the lsoDownloadKbps which is your bandwidth that we store in a local SharedObject and observe the dynamic stream info. The first time you load the page your player will start with the 0 index. Later it should start the player with the most appropriate index for you.)

                 

                2. Take a look at our implementation

                https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/org /osmf/player/media/StrobeMediaPlayer.as

                https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/org /osmf/net/

                 

                Hope this helps,

                Andrian

                • 5. Re: Dynamic Streams always starting with the lowest bitrate ?
                  Philarmon Level 1

                  Thanks guys, now it starts to make sense ...

                   

                  However, i still don't get the main part (sorry for being stupid )

                   

                  How do i get the NetStream and NetConnection if i use the mediaFactory to create my media elements ?

                   

                  Like

                   

                  _currentMediaElement = mediaFactory.createMediaElement(urlResource);

                   

                  I understand that i could subclass the NetLoader if i would go like

                   

                  _currentMediaElement = new VideoElement(urlResource, myNetLoader);


                  but i would love to use the factory and just let it decide how to build stuff.

                   

                  Thank you for your patience with me

                  • 6. Re: Dynamic Streams always starting with the lowest bitrate ?
                    Andrian Cucu Adobe Employee

                    Hi Philarmon,

                     

                    The recommended way to get the NetStream/NetConnection is by overriding the NetLoader (http://forums.adobe.com/message/3028789).

                     

                    Is it a player or a plugin that you are working on? Can you provide more details about your usecase?

                     

                    -Andrian

                    • 7. Re: Dynamic Streams always starting with the lowest bitrate ?
                      Philarmon Level 1

                      The thread you are referring to is also started by me and i still have no idea how to accomplish this

                       

                      It is a player that plays all kind of streams (live, vod, progressive and dynamic), that's why i would love to just use the mediaFactory to let it care about media types, .smil files for dynamic streams etc. As far as i understand all Netconnections, netloaders etc are created internally and there is no real way to access them ?

                       

                      Is there a way to overwrite and use my own netloaders with my approach of using the factory ?

                      • 8. Re: Dynamic Streams always starting with the lowest bitrate ?
                        Andrian Cucu Adobe Employee

                        Hi Philarmon,

                         

                        It looks like I experience exactly the same challenges when working on the StrobeMediaPlayback that you are trying to overcome. I wish it was easier to get the NetConnection and NetLoader and the Resource created by the F4M or SMIL loaders, and I also hope this becomes easier in a future OSMF version.

                         

                        I created my own custom MediaFactory *https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/org /osmf/player/media/StrobeMediaFactory.as) and I replaced the loaders for both RTMP and HTTP dynamic streaming with my custom loaders.

                         

                        Try browsing the source of the StrobeMediaPlayback to see how I use it there: https://sourceforge.net/adobe/smp/svn/LATEST/tree/trunk/player/StrobeMediaPlayback/src/

                         

                        While you look at the code, you might also review it and provide some improvement feedback

                         

                        Thank You,

                        -Andrian

                        • 9. Re: Dynamic Streams always starting with the lowest bitrate ?
                          charles_newman-SZDpEK Level 1

                          Philarmon,

                           

                          Akamai has a new plugin that handles everything you can do on the Akamai network, including setting the starting bitrate or starting index for dynamic streaming content.  Contact your Akamai sales rep or customer care for info on how to get the plugin.  This should make your life much easier.

                           

                          - charles