MP4 video gateway

Here is what I’m trying to do, and I don’t think it should be that hard. I have video files stored outside of the web root folder. So they are not accessible by URL directly. I need a php script, that when called, will load up the file and present it to the browser. The desired effect is they go to a URL like http://example.com/video.php?file=1234 and the file associated with 1234 starts to play. I can’t use a redirect as I want the URL shown to the user to remain http://example.com/video.php?file=1234. The video’s I’ll be streaming are all MP4 but bonus for supporting other types.

Where do I begin? is it as simple as fopen’ing the file and dumping it’s output?

Hey, got this working with the following

$url = 'http://example.com/moviefolder/1234/tm.mp4';
$headers = get_headers($url);
foreach($headers as $header)
    header($header);
readfile("./1234/tm.mp4");

but I have to put it in the web server path, another way to easily get the headers would be great. Also anyway to combine two movie files this way? play a short intro then the main video?

Sponsor our Newsletter | Privacy Policy | Terms of Service