3
votes

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)/

1
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
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
Thanks for the explanation. Will using flash encoded movie or any other format speed things up? - Michal
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
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

1 Answers

5
votes
  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