Nginx – How to enable streaming when file is delivered through PHP script

nginxphp5video streaming

I'm trying to enable mp4 streaming on my content server. Due to some security fanatics whom I working with all files are delivered through a php script and have the following url format:

http://server.com/cdn/3/getObject?param1=71&param2=1002&file=File1000.mp4

So all streaming requests in the standard format such as the following url fail due to the appended parameter

http://server.com/cdn/3/getObject?param1=71&param2=1002&file=File1000.mp4?start=10.0

I'm currently running nginx with the mp4 streaming module compiled and running. I'm thinking about doing a URL rewrite to enable streaming, but I had no success so far. In addition to that I'll have to enable secure streaming in the next step…

Any help will be highly appreciated.

Update:

It seems that my question is not clear enough.

I don't want to stream my mp4 file using a PHP Script or whatever. My problem is that a PHP Script is used to determine the path of the file, this is due to the fact that I need to ensure that people can't just guess other URL's.
So the getObject Script just returns the requested file without any modification or something if all other parameters fit. The problem now is that this makes it impossible to stream the file. Any try to stream a mp4 file (e.g. with flowplayer) fails, even with the streaming module enabled.

Best Answer

There's no such thing as HTTP Steaming. There are a couple of hacks to simulate it however.

First and oldest is using the Range: header to specify what chunk of the file the client wants. There's nothing stopping a PHP script from sending the correct chunk based on that header, it just has to read in the header and return the proper response header with the file data.

Second is using a server module of some kind that understands the format of the file being streamed and delivers the "correct" amount of data per whatever time-slot. This is what the mp4 module for ngninx is doing. It may be possible to program a PHP script that figures out the data rate of the file and then sends the file at that rate, but I don't know of any, and programming it would be tough.