3

First of all: this is my first question here and I am not a skilled Flash Developer.

I have a movie with FLVPLAYBACK component (Player). I set an external source (Player.source = "http://example.com/movie.mp4) and fully buffer it (using Player.addEventListener(VideoProgressEvent.PROGRESS, bufferVideo)). The movie plays fine. The problem is: I need to able to seek to specified time even few hounded times a second. I have a loop which checkes for certain conditions and starts Seek method (Player.seek(TIME)). It works, but there is visible lag between the seeks. Is is possible to .Seek() instantly? I had something like this working in HTML5, but I wasn't able to achieve proper buffering of movies on all browsers.

I don't want to share full code, because it has lots of unrelated parts between parts of this problem.

Update I've tried FLV (somehow seems that the seek is even slower) and F4V (seems faster, but still there is visible lag)/

Michal
  • 733
  • 2
  • 6
  • 23
  • 2
    I believe you're encountering decompression time. Your mp4 is probably compressed with H.264 (or similar) codec which makes for great filesizes, at the cost of CPU crunching decompression. Each frame requires a reference frame (usually based on a previous frame), ergo playback forward is logical, while playback in reverse requires a constant look-back which induces stuttering. – Atriace Jan 06 '14 at 20:31
  • Layman-English translation to Atraice's comment: Your computer is so busy decompressing the file that it doesn't have adequate power to immediately respond to the seek request. (That's seriously oversimplifying his explanation, of course.) – CodeMouse92 Jan 06 '14 at 22:09
  • Thanks for the explanation. Will using flash encoded movie or any other format speed things up? – Michal Jan 07 '14 at 07:41
  • The only way I know of to seek instantly every time with Flash is to convert the video into an FLV and embed it into the timeline of a MovieClip in the Flash IDE. Could that work for you? – imcg Jan 09 '14 at 20:52
  • @imcg is it even possible to do that from Action Script? I get settings (like the movie url) via a json file. – Michal Jan 10 '14 at 10:26
  • 1
    No, to do it that way you would have to preprocess the film in the Flash IDE first, export as a SWF and load that into your app – imcg Jan 10 '14 at 16:34

1 Answers1

5
  1. make sure you have a good connection
  2. video should be compressed for streaming (makes a huge difference)
  3. play with your bufferTime parameter to get an ideal setting
  4. crate a player with code and dont use the UI component. Youll have more flexibility: http://blog.martinlegris.com/2008/06/03/tutorial-playing-flv-video-in-plain-as3-part-1/

caveat, longer buffer will allow smoother playback, shorter will seek faster but the tradeoff is it will hit the buffer more often... not ideal

mihai
  • 4,184
  • 3
  • 26
  • 27
  • I download the video from localhost and even fully buffer it. It does nothing. – Michal Jan 10 '14 at 10:26
  • @Michal, please elaborate on "it does nothing" – mihai Jan 13 '14 at 19:03
  • there is no difference between downloading from a webserver and a local server (outside of the load time). There is still lag between seeks. – Michal Jan 14 '14 at 08:24
  • No, not yet. But I will. – Michal Jan 16 '14 at 13:00
  • @Michal try that since the flash component in the IDE is not very flexible and might cause CPU bottlenecks where you dont need it. The stripped down code version allows you to only load in memory the elements you need and not everything that adobe decided to stuff into the component. Cheers and let us know how it went. – mihai Jan 17 '14 at 17:29
  • it worked :) I rewrote the entire thing with NetStream and everything works great. Some minor problems from previous version were also cured. Thanks for the help! – Michal Jan 17 '14 at 22:37
  • "Rewrote the entire thing with NetStream" oh boy guess I'm gonna have to do that ;_; – Olin Kirkland Mar 03 '16 at 18:10