By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

PHP Video Uploading

P: 24
Hello everyone...Can someone please, please help me solve a problem I am facing in my project......Basically the project is about uploading videos and viewing them.....When users upload a video (avi, wmv, mov or mpg format) the video will be coverted into .flv format...But I am getting an error....

I am using WAMP server

My converting code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /***************Load FFMPEG *********************************/
  3.  
  4.  
  5.  
  6. $extension = "ffmpeg";
  7.  
  8. $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
  9.  
  10. $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
  11.  
  12.  
  13.  
  14.  
  15.  
  16. // load extension
  17.  
  18. if (!extension_loaded($extension)) {
  19.  
  20. dl($extension_soname) or die("Can't load extension $extension_fullname\n");
  21.  
  22. }
  23.  
  24.  
  25.  
  26. /***********************************************************/
  27.  
  28.  
  29.  
  30. /*****************Get the path to Extention ****************/
  31.  
  32.  
  33.  
  34. $array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);
  35.  
  36. $dynamic_path = "";
  37.  
  38. for ($i=0;$i<sizeof($array_path)-1;$i++)
  39.  
  40. if($array_path[$i]!="")
  41.  
  42. $dynamic_path =$dynamic_path."/".$array_path[$i];
  43.  
  44. /**********************************************************/
  45.  
  46.  
  47.  
  48. /******************set folders*****************************/
  49.  
  50. $flvpath = "flvfiles/";
  51.  
  52. $moviepath = "movies/" ;
  53.  
  54. chmod($moviepath,0777);
  55.  
  56. chmod($flvpath,0777);
  57.  
  58. /*********************************************************/
  59.  
  60.  
  61.  
  62. /******************Upload and convert video *****************************/
  63.  
  64.  
  65.  
  66. if(isset($_FILES["x_URL"]))
  67.  
  68. {
  69.  
  70. $fileName = $_FILES["x_URL"]["name"];
  71.  
  72. $fileNameParts = explode( ".", $fileName );
  73.  
  74. $fileExtension = end( $fileNameParts );
  75.  
  76. $fileExtension = strtolower( $fileExtension );
  77.  
  78. if($fileExtension=="avi" || $fileExtension=="wmv" || $fileExtension=="mpeg"
  79. || $fileExtension=="mpg" || $fileExtension=="mov" )
  80.  
  81. {
  82.  
  83. if ( move_uploaded_file($_FILES["x_URL"]["tmp_name"],$moviepath.$_FILES["x_URL"]["name"])
  84. )
  85.  
  86. {
  87.  
  88.  
  89.  
  90. if( $fileExtension == "wmv" ) {
  91.  
  92. exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
  93. -sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
  94.  
  95. }
  96.  
  97. if( $fileExtension == "avi" || $fileExtension=="mpg" ||
  98. $fileExtension=="mpeg" || $fileExtension=="mov" ) {
  99.  
  100. exec("ffmpeg -i ".$dynamic_path."/".$moviepath."".$fileName."
  101. -sameq -acodec mp3 -ar 22050 -ab 32 -f flv -s 320x240 ".$dynamic_path."/".$flvpath."myflv.flv");
  102.  
  103. }
  104.  
  105. /******************create thumbnail***************/
  106.  
  107. exec("ffmpeg -y -i ".$dynamic_path."/".$moviepath."".$fileName."
  108. -vframes 1 -ss 00:00:03 -an -vcodec png -f rawvideo -s 110x90 ".$dynamic_path."/".$flvpath."myflv.png");
  109.  
  110.  
  111.  
  112. }
  113.  
  114. else
  115.  
  116. {
  117.  
  118. die("The file was not uploaded");
  119.  
  120. }
  121.  
  122. }
  123.  
  124.  
  125.  
  126. else
  127.  
  128. {
  129.  
  130. die("Please upload file only with avi, wmv, mov or mpg extension!");
  131.  
  132. }
  133.  
  134. }
  135.  
  136. else
  137.  
  138. {
  139.  
  140. die("File not found");
  141.  
  142. }
  143.  
  144. ?>

The error I am getting:

Expand|Select|Wrap|Line Numbers
  1. Warning: dl() [function.dl]: Not supported in multithreaded Web servers - use extension=ffmpeg.dll in your php.ini in C:\wamp\www\Test\uploadvideopro.php on line 31
  2. Can't load extension C:\php5/ffmpeg.dll 
Please, please someone help me. Thanks in advance.
Sep 22 '08 #1
Share this Question
Share on Google+
4 Replies


Markus
Expert 5K+
P: 6,050
Sounds like you don't have the ffmpeg dll installed.

Have you?
Sep 22 '08 #2

Atli
Expert 5K+
P: 5,058
The error really says it all, doesn't it.

You can not use this function on multithreaded Web servers, which pretty much all modern servers are.

You will instead have to load the DLL as an extension in your php.ini configuration file.
Sep 22 '08 #3

P: 24
The error really says it all, doesn't it.

You can not use this function on multithreaded Web servers, which pretty much all modern servers are.

You will instead have to load the DLL as an extension in your php.ini configuration file.

Hello Atli,

I checked the php.ini file and there is an extension called: extension=php_ffmpeg.dll

If I need a different extension, which one is it and where can I get it from.

Thanks.
Sep 22 '08 #4

Atli
Expert 5K+
P: 5,058
This actually doesn't make sense...

You are trying to load this extension into PHP, and then you try to execute "ffmpeg" via a shell command.

What are you trying to do here?
Load a PHP extension to do this or use a external application?

This ffmepg extension you are trying to use doesn't seem to be an official PHP extension so I can't really say how it is supposed to work. You will have to find out how to use it from wherever you got it.

But, like I said in you other thread, if you plan on using a shell command, the application you are trying to execute has be be installed and working properly outside PHP first.
A good way to test this to try to command in your OS's CLI first to see if it works.
Sep 23 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.