3

I am implementing a video player in Actionscript and I need to be able to define the starting play time for the videos. Netstream.seek(pos) works for flv files but fails for H.264 files (the player starts playing the video from the beginning). Anyone knows what might be the problem?

(I am using Netstream for this instead of adding a parameter with the starting time when I call the Netstream.play method because I don't have Flash Media Server).

luis
  • 1,849
  • 3
  • 16
  • 17
  • are you getting your streams from the server? – www0z0k Mar 11 '11 at 19:33
  • I am using sample MP4 files that I found on the web (i.e. http://h264.code-shop.com:8080/trailer2.mp4). – luis Mar 11 '11 at 19:35
  • i think the problem is that not all servers support seek functionality – www0z0k Mar 11 '11 at 19:57
  • the issue seems to be related with the fact that seeking only works for MP4 streaming when the video has keyframes defined. in this situation I should be able to seek to a position that contains a keyframe. I am still not sure about this, but that's a possibility. I also tried to play local files and it didn't work. – luis Mar 11 '11 at 21:09
  • 1
    you need `canseekontime = true` in video metadata and server support. for seeking to a keyframe you need to find a fileposition in `keyframes.filepositions` with the same index as `keyframes.times` item that's closest to your target time. after you know it you'll have to do something like `stream.play(path.extension?start=12345[fileposition you need])` depending on server implementation – www0z0k Mar 11 '11 at 23:10

2 Answers2

2

Flash does not support sending bytes header, so you will always get byte 0-. You can accomplish seek by utilizing pseudo streaming ( http://h264.code-shop.com/trac ). Basicly, you supply a get param ?start=1234, then the server backend patch the moov header, move it to the front of the file, and start serving it at the start position. (Essentially, splitting the file on the fly, with start position at 1234, and serving up the new generated file)

Jon Skarpeteig
  • 4,118
  • 7
  • 34
  • 53
0

I know for a fact that this works with the latest Red5 1.0 builds, I cannot speak for FMS or Wowza.

Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131