Playing Video Files


I need to know how to stream a video file (such as a .wmv or.avi) directly from my web page. (In the same manner that something such as myspace does) I’ve googled and drifted though tons of sites but no one seems to know how to do this with PHP. Please help.


I believe that they use Flash. I would check, but where I work we are not allowed out to those types of site. Anyway, if you are really interested in do this I would look into this. Using Flash/Actionscript and PHP you should be able to accomplish this.


Actually I did that for several sites. Most of the sites are using flash players, so you will have to convert video files in fo FLV format. To do that on the linux server most likely you will have to use mencoder to encode and flvtool2 to fix the time of the movie (seem to be a bug of mpencoder).

Than you will have to use one of flv players available in the Internet just to play the flv file.

The other method is to use embeded QT player or MS Media player on the page. But this method is not so good because for example I do not have both of that players under linux :)

here is some code that should be executed through exec() function on the server (if allowed in config) to convert video:

exec("mencoder {$config[vdodir]}/{$vdoname} -o {$config[flvdodir]}/{$vid}x.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=9600:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -srate 22050");
exec("flvtool2 -Uv {$config[flvdodir]}/{$vid}x.flv {$config[flvdodir]}/{$vid}.flv");

I think variables usage is quite clear.