tags:

views:

122

answers:

1

I want to know if it's possible to get a remote flv file and have it 'stream' using PHP and exec function. I have 'curl' in my environnement so i want something like :

exec ('curl http://myhosts.com/myflv.flv', $out);
print $out;

Problem is that $out is returned as an array; i want to output the 'raw' stream returned by curl.

+1  A: 

You should be able to use fpassthru() for that, although it would probably be better to just redirect the user to the proper URL instead.

$fp = fopen('http://myhosts.com/myflv.flv', 'rb');
fpassthru($fp);

Or redirect:

header('Location: http://myhosts.com/myflv.flv');

Come to think of it, you should even be able to use readfile()

readfile('http://myhosts.com/myflv.flv');

At any rate, if you can simply redirect the user, do that. It's way more efficient.

Josh Davis
Well, first option seems to work. My next deal is the PHP execution max timeout; if my flv is really big, php will obviously timeout. What would be another alternatives you think ?
Disco
First off, when you say "my flv" I assume you're still talking about remote files. If the file is accessible locally, you should most definitely access it locally. Secondly, while redirecting using a `Location` header is still the method to prefer, it is my understanding that the max execution timeout cannot stop the execution of a PHP function, therefore it cannot stop `readfile()` or `fpassthru()`
Josh Davis
The FLV's are hosted on another server the only way that i have to access them is thru web ... will try your recommendations. Thanks.
Disco