Jump to content

Fread is slow, Is there a better way?


kmaid

Recommended Posts

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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.