Search code examples
phpflashvideostreaming

Streaming video file?


I need to stream an flv file. Streaming should look like live streaming, and I there should be a way to change the target file.
Sorry for my poor English.


Solution

  • If by "streaming" you mean "showing a flash-video clip", flv-streaming isn't really streaming, but it's a normal file transfer, with the flash player starting playback even if the file isn't completely downloaded to the client. Time seeking is implemented in a standard HTTP way, with a file download offset - if you scroll the video halfway on the timeline and it hasn't downloaded yet, the current download is (most often) aborted, and restarted with an offset of filesize/2 bytes.

    So, you could be fine with just using plain old readfile() and fixing the HTTP mime-type headers appropriately with header(). But, since you'd need seeking, you need to parse the HTTP request and instead of readfile(), use fpassthru(), seeking the right place, instead.

    tl;dr: Avoid handling this on the PHP side, and let Apache (or the httpd of your choice) handle this instead.