pull up a video file from database

Posted on 2004-08-12
Last Modified: 2006-11-17
HI to all..

        I have a question here and hope some one could help me out with this.  I am trying to bring out a video file directly from the database using Mysql.  And I want it to be shown on the display page with options such as play, stop, and a small scroll bar.  What should i do about this?  It is like a previewing page of the video file.  And then I would like to add a link below to let ppl download the file.  Could anyone help me??

Thanx Thanx so much ...
Question by:Kaiwap

Expert Comment

Comment Utility
First off, storing images (videos are just a bunch of images) in ANY database (such as MySQL) is a very very bad idea but you could still do it.

The SQL for the structure of the DB should be:

bin_data LONGBLOB,
filename CHAR(50),
filesize CHAR(50)

As far as the play, stop, and scroll bar...I think you are better off posting it in the Java section of this site, and then using PHP's Java functions to implement the code.

Although, I suppose it is somewhat possible to do this via POST or GET methods...but that involves refreshing the page and then you have to code a complicated pause feature and well...I'd use Java.

Alternatively, if you STILL want to do the whole pause/play deal, look into the Windows Media Player Web Services or/and RealOne.

For the link, you can do:
Note: I want to write this using the MySQLi extension for PHP5, but I'm not sure if you do have PHP5 or the MySQLi here's the PHP4 take on it.


echo "Error: " . mysql_error() ."";
if(!@mysql_select_db('videos')) // assumes your database name is 'videos'
echo "Error: " . mysql_error() ."";

$video = mysql_fetch_array(mysql_query("SELECT id,filename from videos where id=$_GET[movieid]")); // so assuming that the URL has &movieid=9 or the number of the ID in the database for that movie

$path = basename($path, "".$_SERVER['PHP_SELF']") . $video['filename'];

echo "<a href='$path'>Download ". $video['filename'] ." now!</a>";

LVL 25

Expert Comment

Comment Utility
Some databases have very good video support, such as Frontbase and Oracle. Most video formats are totally passive (AVI, Real and WM, all of which are essentially play-only, with only laughable data support), offering very little in the way of depth. QuickTime is the exception. With a suitable database it's possible to submit a query that does the equivalent of "find me a point in any of these movies where someone says "hello" in Japanese or Spanish", and have it deliver you the movie cued up (streamed directly from the database) at the appropriate point. Just because MySQL doesn't cut it doesn't mean it's always a bad idea.
Because QuickTime supports reference movies, it's possible to store very small movies (say 20k) in blob fields that themselves contain references to larger movies stored externally (like te "click to play" frames on Apple's trailers site), or even meta-movies that do their own XML queries to find their movie data dynamically. This would work well in MySQL.
Link movies are a great way of sticking 20 movies on 1 page without being killed by the bandwidth requirements of loading them all at once - just click one and it will play in place, without a page refresh.

For controlling movies after loading, all the major formats' plugins have javascript-accessible functions to play/stop rewind, jump to point etc. They all also have their own built in controllers.

Author Comment

Comment Utility
HELLO , to the administratives.    
        Can you help me merge the two topics together as I accidently posted it twice.  And the points i wanted to post is still 250, can you refund that for me too??  thx alot

Author Comment

Comment Utility
I've had a easy one here:

<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="480" height="320" codebase="">
<param name="SRC" value="">
<param name="AUTOPLAY" value="true">
<param name="VOLUME" value="100">
<param name="CACHE" value="true">
<param name="TYPE" value="video/quicktime">
<param name="PLUGINSPAGE" value="">
      <embed TYPE="video/quicktime"
            BGCOLOR="#ffffff" WIDTH=322
            HEIGHT=258 PLUGINSPAGE=""
            AUTOPLAY="TRUE" VOLUME="100" CACHE="TRUE">

Thanx for all your help ..  

Accepted Solution

modulo earned 0 total points
Comment Utility
PAQed with points refunded (250)

Community Support Moderator

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now