14 Replies Latest reply on Sep 17, 2014 2:16 AM by Gaius Coffey

    OSMF HTTP Stream seek bug...

    Gaius Coffey Level 2

      (This was also posted in Flash as I couldn't find the OSMF forum!)

       

      Hi,

      I have built an OSMF player that allows users to seek to where they were when resuming, but also to scrub back to the beginning.

       

      EG:

       

      A stream is 1 minute long.

      User starts play at 25 seconds.

      User can scrub back to 5 seconds or forward to 55 seconds.

       

      This works perfectly with RTMP - TimeTrait reports correctly and video displays correctly.

       

      EG:

      Start at 25 seconds, TimeTrait reports: duration = 60, current position = 25 and displaying video is 25.

      Seek to 5 seconds rewinds to current duration = 60, position = 5, displaying video is 5.

       

      But...

       

      With HTTP streams...

      Start at 25 seconds. TimeTrait reports: duration = 60, current position = 25 and displaying video is 50.

      Seek to 5 seconds rewinds to before the start of the stream and gives me a media complete... end of stream.

      Start at 30 seconds, TimeTrait reports duration = 60, current position = 30 and displaying video is 60 so gives me a media complete... end of stream.

       

      It is pretty clear that what is happening is that HTTP stream seeking is resetting my start index to the seek point, as if I had started play with:

       

      NetStream.play(seekPoint);

       

      Rather than:

       

      NetStream.play();

      NetStream.seek(seekPoint);

       

      This, I hasten to add, is a horrendous issue from my client's point of view as it effectively means I cannot allow resume of content.

       

      Does anybody have any ideas, workarounds?

       

      G

        • 1. Re: OSMF HTTP Stream seek bug...
          Silviu Vergoti Adobe Employee

          Hi,

           

          please use the latest OSMF and, if it still replicates, please provide a stream example and sample code.

          • 2. Re: OSMF HTTP Stream seek bug...
            Gaius Coffey Level 2

            Hi,

            I am using OSMF2.0.2494, where can I check if this is the most current?

            G

            • 3. Re: OSMF HTTP Stream seek bug...
              TheRossman Level 1

              When you say HTTP stream are you talking about just progressive HTTP download of the video, or are you using HDS/HLS?

               

              If the former, you probably do not have enough keyframes in your video file - you don't notice this over RTMP because FMS will generate a keyframe for wherever you wish to seek to (one of it's best features).

              • 4. Re: OSMF HTTP Stream seek bug...
                Gaius Coffey Level 2

                Thanks, Rossman, yes, it is the HTTP streaming media rather than RTMP, but it isn't a frame issue - that would only account for jumping a few seconds out.

                 

                EG: If it was a frame issue:

                Request 38.6 seconds and play 35 seconds or something.

                 

                What is happening instead is:

                Request 38.6 seconds, jump to 38.6 seconds, reset index to zero, jump another 38.6 seconds and start play from 77.2 seconds but report it as 38.6 seconds. In other words, if I seek to anywhere beyond half way, I will just see an end of stream error!

                 

                For now, I have put in a hack / workaround that starts play at 0, waits for the first TimeTrait update and _THEN_ does the seek. In this way, it will play from the point I want with just an occasional flash at the first frame. Not ideal, but at least customers see the content they want.

                 

                G

                • 5. Re: OSMF HTTP Stream seek bug...
                  TheRossman Level 1

                  Sorry I misunderstood.  That is an odd one to be sure...

                  • 6. Re: OSMF HTTP Stream seek bug...
                    ghkindel Level 1

                    Encountered something like this using the apple-http-osmf (HLS) plugin and believe it's a bug OSMF's FLVTag.as, as the first DTS (Decode Time Stamp) being read out at the begining of my streams are actually negative signed ints, whereas FLVTag.timestamp is force casting them as a unsigned int.  In HTTPNetStream, this timestamp, huge because of the casting, leads to a bad initialTime which is added to every seek offset, causing every seek to jump very far ahead and/or end the video. Fixing the cast seems to have fixed it.   Would be great if this could get patched in truck by someone who could expedite it.

                    • 7. Re: OSMF HTTP Stream seek bug...
                      Gaius Coffey Level 2

                      Thanks, ghkindel, I'll take a look.

                      G

                      • 8. Re: OSMF HTTP Stream seek bug...
                        Gaius Coffey Level 2

                        Hi,

                        The only thing I can find that seems relevant is the timestamp value, is this the property you mean?



                        public function get timestamp():uint


                        {



                        // noting the unusual order



                        return (bytes[7] << 24) | (bytes[4] << 16) | (bytes[5] << 8) | (bytes[6]);


                        }





                        public function set timestamp(value:uint):void


                        {



                        bytes[7] = (value >> 24) & 0xff; // extended byte in unusual location



                        bytes[4] = (value >> 16) & 0xff;



                        bytes[5] = (value >> 8) & 0xff;



                        bytes[6] = (value) & 0xff;


                        }

                        Thanks,

                        G

                        • 9. Re: OSMF HTTP Stream seek bug...
                          ghkindel Level 1

                          That looks right.  This is the change I was thinking:

                          org.osmf.net.httpstreaming.flv.FLVTag <          public function get timestamp():uint

                          >          public function get timestamp():int

                          <          public function set timestamp(value:uint):void >          public function set timestamp(value:int):void

                          Because of the signed DTS used in the HLS library, which for my test video is -9000 first frame, 0 second, 9000 third:

                          at.matthew.httpstreaming.HTTPStreamingMP2PESVideo
                          
                                    var dts:Number = 
                                         ((packet.readUnsignedByte() & 0x0e) << 29) + 
                                         ((packet.readUnsignedShort() & 0xfffe) << 14) + 
                                         ((packet.readUnsignedShort() & 0xfffe) >> 1);
                                         
                                    _timestamp = Math.round(dts/90);
                          

                          This may not be directly relevant if you're not using matthew's HLS library, but HTTPNetStream assumes this value is signed:

                                    private function onTag(tag:FLVTag):Boolean
                                         ... 
                                         var currentTime:Number = adjustCurrentTime((tag.timestamp / 1000.0) + _fileTimeAdjustment);
                                         ...
                                         _initialTime = currentTime;
                                         ...
                                         _seekTarget = offset + _initialTime;
                          

                          This was the resource I was using to debug the DTS value:  http://dvd.sourceforge.net/dvdinfo/pes-hdr.html

                           

                          I couldn't find anything to indicate whether the field should be signed or not, but it definitely is for the first frame in each of my test m3u8/ts files.   It might be that the "right" behavior might also be to zero the timestamp if negative.

                          • 11. Re: OSMF HTTP Stream seek bug...
                            Sunil Kumar Sah Level 1

                            Hi,

                             

                            HTTPNetStream.as not able to use because of SWC component using for entire OSMF framework application. Can you please advise how to use it.


                            I am using below code to play http mp4 video and local video i.e. c:\myfolder\myvideo.mp4  or myfolder/myvideo.mp4 etc.


                                 netLoader = new NetLoader();

                              mediaElement=new VideoElement(urlResource,netLoader);

                              initOSMFPlayer(mediaElement, true);

                             

                            private function initOSMFPlayer(medElement:*, autoStart:Boolean=false):void {

                              //trace("Media Element changed Successfully" +medElement);

                              try {

                              mediaPlayer=new MediaPlayer(mediaElement);

                              mediaPlayer.addEventListener(DisplayObjectEvent.MEDIA_SIZE_CHANGE, _onSizeChange);

                              mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError, false, 0, true);

                              mediaPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, playerStateChange, false, 0, true);

                              mediaPlayer.addEventListener(PlayEvent.PLAY_STATE_CHANGE, currentState, false, 0, true);

                              mediaPlayer.addEventListener(TimeEvent.COMPLETE, videoComplete, false, 0, true);

                              mediaPlayer.addEventListener(MediaPlayerCapabilityChangeEvent.CAN_SEEK_CHANGE, canSeekChange, false, 0, true);

                              mediaPlayer.autoPlay=autoStart;//autoStart;

                              mediaPlayer.bufferTime=1;

                              mediaContainer.visible=false;

                              mediaContainer.addMediaElement(mediaElement);

                              if ((urlType=="HTTP" || urlType=="Undefined") && !autoStart) {mediaPlayer.stop();}

                              stageResize();

                              } catch (e:*) {

                              trace("Error found in loading OSMF FRamework");

                              //trace("MediaPlayer Error: " + e.toString() + " " + e.type);

                              //controller.insertLog("Error found in OSMF Player Framework...");

                              //controller.updatePlayerError(ErrorType.UNSUPPORTED_FORMAT);

                              }

                              }

                             

                            Please advise if any things else need to change to use actual HTTPNetStream.as    ( org.osmf.net.httpstreaming.HTTPNetStream);

                             

                            Please advise.

                            • 12. Re: OSMF HTTP Stream seek bug...
                              Gaius Coffey Level 2

                              Hi Sunil,

                              What you need to do is to download the OSMF code library from SVN. That will give you full access to all classes so as to allow you to make tweaks.

                               

                              You can then import that as a code library to your Flash Builder and either;

                              a) Add the project to your Flash Builder project as a resource

                              b) Compile it and take the new .SWC from bin directory and add it to your /libs directory in the project you want

                               

                              Personally, I like to have it as a project library so as to be able to chase bugs down through the code rather than just seeing a fairly meaningless MediaError has occurred in the console...

                               

                              G

                              • 13. Re: OSMF HTTP Stream seek bug...
                                Sunil Kumar Sah Level 1

                                Hi Gaius,

                                 

                                Thanks a lot for your reply. Actually I did that but still that is not working. HTTPNetStream.as class not found in "OSMF-src\OSMF\framework\osmf" folder so I downloaded it from net externally and created one package same as mention in the class package name then changed that parameters line as mention in "http://forums.adobe.com/message/4641950".

                                 

                                Please advise how to do that and on which folder do I need to compile. I am using Flash CS6 so please advise how to compile it after doing necessary changes. I am using

                                • 14. Re: OSMF HTTP Stream seek bug...
                                  Gaius Coffey Level 2

                                  Ah!

                                  That looks like you have a path error - I think you have put the OSMF source library actually _into_ your /src path for the Flash Builder project.

                                  What you need to do is to take it out again and add it as a coding library instead.

                                  You can then refer to it via ActionScript Build Path

                                   

                                  OSMF.PNG