readfile & .avi files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

readfile & .avi files

Post by nigma »

i've got a video file that I have on my website that i'd like to allow only certain people to see. To accomplish this i've setup a system that uses one-time use urls so that I can link people to the page but then in turn they can't spread the link around. I was planning on using readfile() to display the .avi file while keeping the location secret but nothing is displayed when I do this. At first I thought it might be because of the size of the video is greater than memory_limit but I figure i'd get an error message if that was true.

Any ideas on alternative functions or method of accomplishing the same thing?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the "header" in an .avi comes at the end of the file, therefore, the user must download the entire file before they can determine how to process it. If it were converted to a streaming media, such as WMV or QuickTime, it would start playing relatively quickly, provided the download speed is decent.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

you know of any free converters off hand?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

hmm... i've got the files encoded and uploaded but I still get nothing with readfile(filename.wmv). Any ideas?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Is the problem this that readfile is not returning anything or the file not playing? Are the right headers sent before you output the content (if any comes past readfile) ?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Yea. I was completely unaware that I needed to output the headers myself. I thought readfile would take care of that.

This was the header I needed to output:
header('Content-Type: video/x-ms-wmv');

The only problem with this is that the user can now choose to download the file. :evil:
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

cant you jus' use the online streaming players available on the net or make yourself one using Flash. Whaddya say :wink:
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i don't think memory consumption is an issue with readfile...

i have memory_limit defaults to 8mb and i have served +5000 times a file with size > 25mb without complaints.... :) source => download.txt
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Thanks tim.
Post Reply