The following videos are streamed in mpg format using PHP and MySQL. Instead of pointing the SRC tag to real URL location of .mpg file; it is pointed to a PHP file. The objective of using PHP is to provide a layer of protection/security to the real URL of the video. In this way, it cannot be easily downloaded. The real URL is stored in MySQL database. PHP will grab this real URL corresponding to a specific ID (refer to MySQL table sample below).Since the .mpg file is around 2MB in size, it will take at most 60 seconds to start streaming. I have intended to do this since some PHP functions limit the streaming size.
Serving large video files in PHP can be problematic.This is for
streaming compatibility checking.
Also the embed code player is NOT guaranteed to work in all browsers.
Overview:
You need three files:
a. PHP page where you will embed your movie.(videostreaming.php in this example and is uploaded to the root directory of the website.)
This is the embed code I use (of course you can use your own). In bold, is the obfuscated URL of the actual video path:(the code below assumes you will not be using autostart mode of the video, if you need to enable autostart, set change autostart value from 0 to 1)
Update: February 4, 2011: Do not use autostart="false" , instead use autostart="0" because using "false" won't work in Windows Firefox.
b. PHP script to get the real URL stored in MySQL database. This needs to be uploaded to the root directory of your server Download source code here
c. MySQL table-you need to create one in your existing database.See screenshot below:(Update: February 4, 2011: Use absolute server path instead of using http://www.example.com/videofolder/movie.mpg because PHP readfile function won't read the video if the folder is .htaccess protected. See screenshot for the sample absolute server path location to the video, under MySQL "realurl" field name.Read this tutorial on how to get the absolute server path name to the file in your server.
d. Update: February 4, 2011. To protect the video inside the folder from any possible downloading, place .htaccess inside that folder with the command Deny from all.
For details, refer to this Developer Shed Tutorial on Video
Streaming PHP Script.
Demo Video title: Apollo 14 Lunar Module Ascent in Earth's moon
(1971)(Will take at most 1 minute to load depending on your internet
speed.)