PHP Video Uploading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scan87
    New Member
    • Feb 2007
    • 24

    PHP Video Uploading

    Hello everyone...Can someone please, please help me solve a problem I am facing in my project......Ba sically 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:

    Code:
    <?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");
    
    }
    
    ?>

    The error I am getting:

    Code:
    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
    Can't load extension C:\php5/ffmpeg.dll
    Please, please someone help me. Thanks in advance.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Sounds like you don't have the ffmpeg dll installed.

    Have you?

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      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.

      Comment

      • scan87
        New Member
        • Feb 2007
        • 24

        #4
        Originally posted by Atli
        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_f fmpeg.dll

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

        Thanks.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          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.

          Comment

          Working...