Upload Video PHP any help appreciated

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
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Upload Video PHP any help appreciated

Post by scarface222 »

Hey guys, just wondering if anyone knows the best way to approach uploading videos. I want the user to be able to upload multiple videos and access them on a page after. Should I have the video converted to flash and if so do I need to install ffmpeg on the server? I have never done this so I am confused on how to approach it. I found a script but it gives the error

Warning: dl() [function.dl]: Not supported in multithreaded Web servers - use extension=ffmpeg.dll in your php.ini in C:\Web Files\wamp\www\browsestart\includes\videoupload.php on line 26
Can't load extension C:\php5/ffmpeg.dll

even when I add the ;extension=php_ffmpeg.dll extension to php.ini. The script I am using is below. Anyone have any ideas on how to approach this? I am not sure if this is a good way to approach this with this script.

Code: Select all

<?php
/***************Load FFMPEG *********************************/
 
 
 
$extension = "ffmpeg";
 
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
 
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
 
 
 
 
 
// load extension
 
if (!extension_loaded($extension)) {
 
dl($extension_soname) or die("Can't load extension $extension_fullname\n");
 
}
 
 
 
/***********************************************************/
 
 
 
/*****************Get the path to Extention ****************/
 
 
 
$array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);
 
$dynamic_path = "";
 
for ($i=0;$i<sizeof($array_path)-1;$i++)
 
if($array_path[$i]!="")
 
$dynamic_path =$dynamic_path."/".$array_path[$i];
 
/**********************************************************/
 
 
 
/******************set folders*****************************/
 
$flvpath = "flvfiles/";
 
$moviepath = "movies/" ;
 
chmod($moviepath,0777);
 
chmod($flvpath,0777);
 
/*********************************************************/
 
 
/******************Upload and convert video *****************************/
 
 
 
if(isset($_FILES["x_URL"]))
 
{
 
$fileName = $_FILES["x_URL"]["name"];
 
$fileNameParts = explode( ".", $fileName );
 
$fileExtension = end( $fileNameParts );
 
$fileExtension = strtolower( $fileExtension );
 
if($fileExtension=="avi" || $fileExtension=="wmv" || $fileExtension=="mpeg"
|| $fileExtension=="mpg" || $fileExtension=="mov" )
 
{
 
if ( move_uploaded_file($_FILES["x_URL"]["tmp_name"],$moviepath.$_FILES["x_URL"]["name"])
)
 
{
 
 
 
if( $fileExtension == "wmv" ) {
 
exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
-sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
 
}
 
if( $fileExtension == "avi" || $fileExtension=="mpg" ||
$fileExtension=="mpeg" || $fileExtension=="mov" ) {
 
exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
-sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
 
}
 
/******************create thumbnail***************/
 
exec("ffmpeg -y -i ".$dynamic_path."/".$moviepath."".$fileName."
-vframes 1 -ss 00:00:03 -an -vcodec png -f rawvideo -s 110x90 ".$dynamic_path."/".$flvpath."myflv.png");
 
 
}
 
else
 
{
 
die("The file was not uploaded");
 
}
 
}
 
 
 
else
 
{
 
die("Please upload file only with avi, wmv, mov or mpg extension!");
 
}
 
}
 
else
 
{
 
die("File not found");
 
}
?>
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Re: Upload Video PHP any help appreciated

Post by scarface222 »

Anyone familiar with developing with video upload scripts?
skullmunky
Forum Newbie
Posts: 12
Joined: Fri Apr 17, 2009 10:25 pm

Re: Upload Video PHP any help appreciated

Post by skullmunky »

Disclaimer: I have exactly zero experience with this, so everything I say may be totally wrong.

ok, with that out of the way:

1. That seems like a reasonable way to go (upload the video and convert it with ffmpeg).
2. it looks like there are two uses of ffmpeg: the first is the conversion, which is just done with a command line call through exec(). the second is the ffmpeg-php extension which you would use to grab frames from a movie, get info from it, but not convert it.

3. http://www.php.net/dl explains what the error is you're getting when you try to use dl(), and what you should do instead. But first try ths only with the conversion exec's, leave out the use of the extension, and see what that does.
Post Reply