kmaid Posted September 23, 2007 Share Posted September 23, 2007 Hi again all! I have been trying to stream a 19mb quicktime file through PHP. While this script does work i find it to be really slow. Is there any way i can make it faster? I have tried using fpassthru and using a smaller buffer and neither seemed to have much effect. Here is the code im using thanks for your help Kmaid $filename = "Trailer.mov"; header("Content-Disposition: atachment; filename=$filename"); header("Content-Type: video/mov"); header("Content-Length: ".filesize("$filename")); $fp=fopen("$filename","r"); print fread($fp,filesize("$filename")); fclose($fp); Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/ Share on other sites More sharing options...
marcus Posted September 23, 2007 Share Posted September 23, 2007 Does it time out? Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353165 Share on other sites More sharing options...
kmaid Posted September 23, 2007 Author Share Posted September 23, 2007 Nah it doesnt time out, it works fine its just that if i download the file directly i get 120kbs speeds and if i download it via the PHP script i seem to be getting closer to 30-40kbs. Im wondering if this is a phpini setting or somthing its just incredibly slow. Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353166 Share on other sites More sharing options...
marcus Posted September 23, 2007 Share Posted September 23, 2007 It could be based on your server speed. Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353167 Share on other sites More sharing options...
kmaid Posted September 23, 2007 Author Share Posted September 23, 2007 I dont think that is the issue, the server is dedicated and this script is currently its only task the specifications are Processer: AMD Athlon 3200 Ram: 1024MB Hard drive: 160GB Port: 100mbs Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353173 Share on other sites More sharing options...
remlabm Posted September 23, 2007 Share Posted September 23, 2007 try using fsocketopen() http://us3.php.net/manual/en/function.fsockopen.php should make it a bit faster. Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353220 Share on other sites More sharing options...
kmaid Posted September 23, 2007 Author Share Posted September 23, 2007 I tried fsocketopen and it didnt appear to make much diffrence. I see othersites offering normal speeds and when i download the "Trailer.mov" i max out my connection. There just has to be some setting or somthing as i see othersites providing normal speeds through phpscripts. Has anyone else had this issue or is this somthing strange? Thanks again for the help so far -Kmaid Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353566 Share on other sites More sharing options...
rarebit Posted September 23, 2007 Share Posted September 23, 2007 ? http://uk3.php.net/manual/en/function.fpassthru.php Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353568 Share on other sites More sharing options...
kmaid Posted September 24, 2007 Author Share Posted September 24, 2007 Nah im afraid its one of the first things i tried. Would the memory limit of the php script make a big diffrence? i am just using a default plesk configuration on the server hosting the video or are there any limits which slow the scripts down? Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353934 Share on other sites More sharing options...
rarebit Posted September 24, 2007 Share Posted September 24, 2007 What about having a link to a stream from something such as vlc and let that handle it? Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353937 Share on other sites More sharing options...
kmaid Posted September 24, 2007 Author Share Posted September 24, 2007 I just opened up the direct link to the quicktime file in VLC and it didnt stream as perfectly as it should however I then used the direct link in the offical quicktime player and it was fine. I then tried using the php file in VLC which wouldnt work at all. Using quicktime it bufferd and was at the slow 30ish kbs rate. The movie is about 4mins 30 and only 18.4 MB so streaming it at normal broadband speeds shouldnt be an issue i can promise this is down to somthing in my script or webserver configuration x.X! I am going to try installing xampp on one of my other dedis and see if a diffrent php configuration makes a diffrence. Quote Link to comment https://forums.phpfreaks.com/topic/70305-fread-is-slow-is-there-a-better-way/#findComment-353954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.