3 Replies - 8020 Views - Last Post: 19 June 2011 - 06:00 PM Rate Topic: -----

#1 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,852
  • Joined: 30-April 10

Uploading and viewing video using PHP and a database

Posted 18 June 2011 - 05:31 PM

I am working on a conceptual project that is a site allowing registered users to upload their music videos and I want to then post them on the site.

My questions are:

What would be the best way to store the videos;
Now I have the thought of saving the videos after upload to a folder dedicated to the user that is logged in and save the information about that video to a database for retrieval purposes.

Is this a good way or is there a more secure/better way to do this?

Also, what is the best and easiest way to display them in the browser so that all users can view them, will I need to convert them to one format on save or upload?

Thank you in advance to anyone that can give me some pointers.

Is This A Good Question/Topic? 0
  • +

Replies To: Uploading and viewing video using PHP and a database

#2 maniacalsounds  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 472
  • Joined: 27-June 10

Re: Uploading and viewing video using PHP and a database

Posted 18 June 2011 - 05:35 PM

I'm not quite sure the "best way" to do this, I'm only sure of one way - doing some HTML form trickery and then move the tmp file to the new location.

Some good reading (images and videos are uploaded practically identically):
http://webdeveloper....ad.php?t=101466

make sure your HTML form includes:
enctype="multipart/form-data"


^^ That allows multimedia (pictures/video) to be uploaded as well. Read the tutorial/forum for actually processing it with PHP.

Hope I helped. :)
Was This Post Helpful? 0
  • +
  • -

#3 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3718
  • View blog
  • Posts: 5,989
  • Joined: 08-June 10

Re: Uploading and viewing video using PHP and a database

Posted 18 June 2011 - 06:21 PM

*
POPULAR

View Postlaytonsdad, on 19 June 2011 - 12:31 AM, said:

Is this a good way or is there a more secure/better way to do this?

That is a good way. The ideal way to store large binary objects (videos, audio, images, large PDFs, etc...) is to place them somewhere on the file-system and put their location into the database where you store the meta-data.

Placing the binary data into the database is possible, but inefficient. At least, using the typical RDBMS genre of databases. Other types, like certain NoSQL types, may be better suited for large databases of binary objects.

Personally I like to use the unique ID your database presumably generates for the video as the physical name of the file on the file-system, and then if needed use a script to set the name in the request headers on retrieval using data from the database. - It may not be ideal in all situations, but it makes things a little more organized.

View Postlaytonsdad, on 19 June 2011 - 12:31 AM, said:

Also, what is the best and easiest way to display them in the browser so that all users can view them...

That is a complex question. Unfortunately browser support for audio and video files varies greatly, but with the introduction of HTML5 video and audio tags most modern browsers can natively support one format or another. - Microsoft stubborn refuses to use anything but H.264 (they apparently own a part in the patent on it...) while Chrome will soon have H.264 support removed (due to it being patented, and thus not free to use... or so we are told) so a single cross browser supported format is not likely to be available soon. But if you dual encode videos in H.264 (for IE) and VP8 or Ogg/Theora (for the rest) then you should be able to cover the full spectrum of the major browsers.

An alternative to that -- either as a replacement for HTML5 video, or just for browsers that don't support HTML5 video -- is using Flash to deliver the media. Sites like YouTube have been doing for ages, but that requires the Flash Player plugin. Granted, this is installed already on a vast majority of browsers (thanks in large part to said Google owned multimedia giant), but it's still a 3rd party plugin so there is no guarantee it is there. - The upside is that with this you can use a single file-format (usually H.264).

View Postlaytonsdad, on 19 June 2011 - 12:31 AM, said:

... will I need to convert them to one format on save or upload?

Typically you would convert them to the format you want it delivered as when they are uploaded. You can of course set up a secondary server to do this, so not to continuously drain the HTTP server itself of all it's resources. - Multimedia conversion is a resource intensive task. On a busy site, you are more than likely going to need a whole separate machine, or even several machines, dedicated to this.

Tools like FFmpeg can be used to accomplish this task.
Was This Post Helpful? 5
  • +
  • -

#4 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,852
  • Joined: 30-April 10

Re: Uploading and viewing video using PHP and a database

Posted 19 June 2011 - 06:00 PM

@Atli
Thank you for your response that is what I was looking for. I was aware of most of that but wanted to see if there was a more efficient way.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1