VideoHelp Forum

Try DVDFab and copy Ultra HD Blu-rays and DVDs! Or rip iTunes movies and music! Download free trial !
+ Reply to Thread
Results 1 to 27 of 27
Thread
  1. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    I've searched and googled but I could not find much in the way of installing, setting up and testing ffmpeg/flvtool2 on Windows when it is to be used with PHP for a website.

    Can one of you who's already done this help me, please

    I am putting together a website that will let users upload small videos so they can be streamed on the website but I can't get a particular script to work. It does not even recognize the paths to ffmpeg or flvtool2.

    The server is Windows 2003 R2 running Apache 2.20 and PHP 5.3.8. I found the correct binaries of ffmpeg and flvtool2 and I have installed them. I also installed ffmpeg-php and loaded the extension.

    Below is a screencap of phpinfo():




    The paths below are correct and also come from phpinfo():

    C:\ffmpeg\bin;C:\flvtool2\bin;C:\ffmpeg\ffmpeg-php



    If I use the following script to test ffmpeg, it works:
    PHP Code:
    <?php
    $ffmpegpath 
    "ffmpeg.exe";
    $input '1.mp4';
    $output '1.jpg';
     
    if (
    make_jpg($input$output)){
     echo 
    'success';
    }else{
     echo 
    'bah!';
    }
     
    function 
    make_jpg($input$output$fromdurasec="01") {
     global 
    $ffmpegpath;
     
     if(!
    file_exists($input)) return false;
     
    $command "$ffmpegpath -i $input -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output";
     
    @
    exec$command$ret );
     if(!
    file_exists($output)) return false;
     if(
    filesize($output)==0) return false;
     return 
    true;
    }
    ?>
    Can someone please provide me with a different, simple PHP test script with debugging that will test both ffmpeg and flvtool2?

    I don't know PHP or ffmpeg/flvtool2 well enough to write it myself. I've already tried but it did not work and I don't know if it's because something is wrong with my installation or the coding. I need something that's proven to work.

    The problem I have with the video sharing script I want to use is that the script does seem to like the path to ffmpeg or flvtool2 so I can't even get past the first step to setting it up.

    Here's a screencap of the first setup step of the video script:

    Before I enter the paths:



    After I enter the correct paths:




    Here's the code for that part of the script:
    PHP Code:
    <?php
    $page 
    "admin_install_vid";
    include 
    "admin_header.php";
     
    if(!isset(
    $_GET['ffmpeg_path']) OR !isset($_GET['flvtool2_path']))
    {
          
    // show form
          
    if(in_array('exec'explode(','ini_get('disable_functions'))))
          {
                
    // exec is disabled on this server
                
    $smarty->assign('result''The php function "exec" [<a href="http://www.php.net/manual/en/function.exec.php" target="_blank">http://www.php.net/manual/en/function.exec.php</a>] is disabled on this server.<br><br>Please enable this function by editing the "disable_functions" variable in your php.ini file');
          }
    }
    else
    {
          
    // verify that ffmpeg is installed
          
    $ffmpeg_path escapeshellcmd(strip_tags($_GET['ffmpeg_path']));
     
          
    $is false;
          
    $result null;
          
    exec($ffmpeg_path.' -version'$result);
     
          if(empty(
    $result) || !isset($result[0]) || !strstr($result[0], 'FFmpeg'))
          {
                
    $is false;
                
    $smarty->assign('result''The FFmpeg installation could not be found. Try again.');
          }
          else
          {
                
    $is true;
          }
     
          
    // verify that ffmpeg is installed
          
    $flvtool2_path escapeshellcmd(strip_tags($_GET['flvtool2_path']));
     
          
    $result null;
          
    exec($flvtool2_path.' -H'$result2);
     
          if(empty(
    $result2) || !isset($result2[0]) || !strstr($result2[0], 'FLVTool2'))
          {
                
    $is false;
                
    $smarty->assign('result2''The FLVTool2 installation could not be found. Try again.');
          }
          else
          {
                
    $is true;
          }
    }
     
    if (
    $is == true) { $smarty->assign('is''Your server has got all All-in-one Video Plugin requirements.'); }
     
    $smarty->assign('flvtool2_path'$flvtool2_path);
    $smarty->assign('ffmpeg_path'$ffmpeg_path);
    include 
    "admin_footer.php";
    ?>
    I don't know how to debug. Also, the flvtool2 package I downloaded contains 'C:/flvtool2/bin/flvtool2' and 'C:/flvtool2/flvtool2.exe'. Which am I supposed to use?

    I've tried specifying both files for the flvtool2 path but it makes no difference.
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Try change the path slashes to double backslashes like
    Code:
    c:\\ffmpeg\\bin\\ffmpeg.exe
    c:\\flvtool2\\flvtool2.exe
    Quote Quote  
  3. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Thanks for the response

    I already tried that. Made no difference. It also populateed the input box with...

    C:^\^\^\^\ ffmpeg^\^\^\^\bin^\^\^\^\ ffmpeg.exe

    ...after I click on the validate button.

    I'm not sure what I did, but now the same path to flvtool2 is being accepted.



    I tried that path earlier and it did not work
    Last edited by jeffshead; 18th Oct 2011 at 16:12.
    Quote Quote  
  4. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    I'm not sure what I did, but now the same path to flvtool2 is being accepted.

    I tried that path earlier and it did not work
    Are you sure?

    The path to ffvtool2 is different in posts #1 and #3:
    C:/ffvtool2/bin/ffvtool2 (not found)
    C:/ffvtool2/flvtool2.exe (found)

    Are you sure the path to ffmpeg is correct? What about uppercase/lowercase characters?
    Quote Quote  
  5. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Also, forward slashes in a Windows path is weird. I'd expect backslashes, and for them to be escaped as Baldrick has already mentioned.

    Not sure why doing that has added odd characters to the input box.

    Here's a simple php script to check the paths:
    PHP Code:
    <?php
    // check to see if paths are valid

    $ffmpeg_path "path_to_ffmpeg";
    $ffvtool2_path "path_to_ffvtool2";

    if(
    file_exists($ffmpeg_path)) {
        echo 
    "Found ffmpeg<br>\n";
    } else {
        echo 
    "Can't find ffmpeg<br>\n";
    }

    if(
    file_exists($ffvtool2_path)) {
        echo 
    "Found ffvtool2<br>\n";
    } else {
        echo 
    "Can't find ffvtool2<br>\n";
    }   

    ?>
    Replace the two variables at the top with the paths to ffmpeg and ffvtool2 using \\ instead of \
    Last edited by intracube; 18th Oct 2011 at 17:00.
    Quote Quote  
  6. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Originally Posted by intracube View Post
    Originally Posted by jeffshead View Post
    I'm not sure what I did, but now the same path to flvtool2 is being accepted.

    I tried that path earlier and it did not work
    Are you sure?

    The path to ffvtool2 is different in posts #1 and #3:
    C:/ffvtool2/bin/ffvtool2 (not found)
    C:/ffvtool2/flvtool2.exe (found)

    Are you sure the path to ffmpeg is correct? What about uppercase/lowercase characters?
    Yeah, the path to ffmpeg is correct and so is the case.

    I realize the path to flvtool2 is different in the screencaps. I tried both paths many times. The flvtool2 folder contains the following two files:

    C:/flvtools/bin/flvtools2
    C:/flvtools/flvtools.exe

    I was not sure of which one to use but now I guess the one with the .exe extention is the correct one.

    Only forward slashes works. I've also had to use forward slashes for other PHP scripts.

    I'm at a complete loss here.
    Quote Quote  
  7. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    I might have found an issue with the script for the plugin installation.

    I don't totally understand what the script is doing, but from what I can see it tries to run ffmpeg with the -version parameter, and expects a certain response. Specifically, it expects the response from ffmpeg to start with the string 'FFmpeg'.

    When I try ffmpeg with the -version option, it returns a string starting with 'ffmpeg' - note that it's all lower case.

    I'm running this on Linux and I don't know if the Windows version of ffmpeg differs in operation, but you could try replacing line 23:
    PHP Code:
    if(empty($result) || !isset($result[0]) || !strstr($result[0], 'FFmpeg')) 
    with:
    PHP Code:
    if(empty($result) || !isset($result[0]) || !strstr($result[0], 'ffmpeg')) 
    Quote Quote  
  8. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Originally Posted by intracube View Post
    When I try ffmpeg with the -version option, it returns a string starting with 'ffmpeg' - note that it's all lower case.
    Same here when I run the command directly on the server.

    When I change 'FFmpeg' to all lower case and test, the browser acts like it's waiting for the page to finish loading and none of the links work on the website. Neither a page refresh nor opening a new tab helps and it does this with any browser. I have to totally close the browser and reopen it. Then when I browse back to the page, it does the same thing.Wierd.

    Now I'm really confused. Maybe that fixed the code but now I'm having an issue with ffmpeg itself???
    Quote Quote  
  9. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Where did you get the 'All-in-one video plugin' utility/script from? If I have time tomorrow, I'll try and go through it again and look at the associated files that comes with it.

    Did you try the code in post #5? What was the result?
    Quote Quote  
  10. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Originally Posted by intracube View Post
    Did you try the code in post #5? What was the result?
    I used the script from post #5 and it says the paths are correct.

    I re-downloaded and re-installed both of the following packages:

    http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-git-6bca574-win32-static.7z

    http://x32.elijst.nl/ffmpeg-php53-win32-vc9-all.zip

    Here is the output from the ffmpeg command line version check:
    Code:
     
    C:\ffmpeg>ffmpeg -version
    ffmpeg version N-33698-g6bca574, Copyright (c) 2000-2011 the FFmpeg developers
      built on Oct 16 2011 13:33:14 with gcc 4.6.1
      configuration: --enable-gpl --enable-version3 --enable-runtime-cpudetect --ena
    ble-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-
    libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --ena
    ble-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --en
    able-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
    --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil    51. 21. 0 / 51. 21. 0
      libavcodec   53. 20. 1 / 53. 20. 1
      libavformat  53. 16. 0 / 53. 16. 0
      libavdevice  53.  4. 0 / 53.  4. 0
      libavfilter   2. 43. 6 /  2. 43. 6
      libswscale    2.  1. 0 /  2.  1. 0
      libpostproc  51.  2. 0 / 51.  2. 0
    ffmpeg N-33698-g6bca574
    libavutil    51. 21. 0 / 51. 21. 0
    libavcodec   53. 20. 1 / 53. 20. 1
    libavformat  53. 16. 0 / 53. 16. 0
    libavdevice  53.  4. 0 / 53.  4. 0
    libavfilter   2. 43. 6 /  2. 43. 6
    libswscale    2.  1. 0 /  2.  1. 0
    libpostproc  51.  2. 0 / 51.  2. 0

    I also changed the All-In-One script's code back to all lowercase 'ffmpeg'. Now the browser does not act all weird and the All-In-One script regonizes the paths, uploads the videos but it does not convert them.

    Maybe the ffmpeg and flvtool2 install needs to be fully tested before working on the All-In-One script. I just don't know how to test.

    Nothing happens (just a blank screen with no errors in any logs) when I use the following script to test:

    PHP Code:
    <?php
     
     
     
    // Set our source file
     
    $srcFile "C:/test/clock.avi";
     
    $destFile "C:/test/clock.flv";
     
    $ffmpegPath "C:/ffmpeg/bin/ffmpeg.exe";
     
    $flvtool2Path "C:/flvtool2/flvtool2.exe"
    // Create our FFMPEG-PHP class
     
    $ffmpegObj = new ffmpeg_movie($srcFile);
     
    // Save our needed variables
     
    $srcWidth makeMultipleTwo($ffmpegObj->getFrameWidth());
     
    $srcHeight makeMultipleTwo($ffmpegObj->getFrameHeight());
     
    $srcFPS $ffmpegObj->getFrameRate();
     
    $srcAB intval($ffmpegObj->getAudioBitRate()/1000);
     
    $srcAR $ffmpegObj->getAudioSampleRate();
     
    // Call our convert using exec()
     
    exec($ffmpegPath " -i " $srcFile " -ar " $srcAR " -ab " $srcAB " -f flv -s " $srcWidth "x" $srcHeight " " $destFile " | " $flvtool2Path " -U stdin " $destFile);
     
    // Make multiples function
     
    function makeMultipleTwo ($value)
     {
     
    $sType gettype($value/2);
     if(
    $sType == "integer")
     {
     return 
    $value;
     } else {
     return (
    $value-1);
     }
     }
     
    ?>
    Last edited by jeffshead; 19th Oct 2011 at 08:16.
    Quote Quote  
  11. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    I also changed the All-In-One script's code back to all lowercase 'ffmpeg'. Now the browser does not act all weird and the All-In-One script regonizes the paths, uploads the videos but it does not convert them.
    You haven't said where you got the all-in-one script from, and I can't tell what it's trying to do from the code you've posted.

    Does the place where you got the code have a support forum or similar? You could try asking there for guidance. If you do, point out the issue with the installation script re FFmpeg/ffmpeg string. It definitely looks like a bug to me. ISTR older versions of ffmpeg *did* report the version with an uppercase FFmpeg string.

    Instead of changing the FFmpeg string to ffmpeg, replacing strstr() with stristr() might be a more elegent way to fix the bug.

    Nothing happens (just a blank screen with no errors in any logs) when I use the following script to test:
    I woudn't have expected the Windows paths with forward slashes to work, but if you tried them with the script in post #5, and it seems to work, then I'm confused.

    I haven't done anything with php classes, so I can't really help with that aspect, but try this:
    PHP Code:
    <?php
     
    // Set our source file
     
    $srcFile "C:/test/clock.avi";
     
    $destFile "C:/test/clock.flv";
     
    $ffmpegPath "C:/ffmpeg/bin/ffmpeg.exe";
     
    $flvtool2Path "C:/flvtool2/flvtool2.exe"
    // Create our FFMPEG-PHP class
     
    $ffmpegObj = new ffmpeg_movie($srcFile);
     
    // Save our needed variables
     
    $srcWidth makeMultipleTwo($ffmpegObj->getFrameWidth());
     
    $srcHeight makeMultipleTwo($ffmpegObj->getFrameHeight());
     
    $srcFPS $ffmpegObj->getFrameRate();
     
    $srcAB intval($ffmpegObj->getAudioBitRate()/1000);
     
    $srcAR $ffmpegObj->getAudioSampleRate();
     
    // Call our convert using exec()
     
    $command $ffmpegPath " -i " $srcFile " -ar " $srcAR " -ab " $srcAB " -f flv -s " $srcWidth "x" $srcHeight " " $destFile " | " $flvtool2Path " -U stdin " $destFile;
     
    exec($command);
     echo 
    $command;
     
    // Make multiples function
     
    function makeMultipleTwo ($value)
     {
     
    $sType gettype($value/2);
     if(
    $sType == "integer")
     {
     return 
    $value;
     } else {
     return (
    $value-1);
     }
     }
    ?>
    It will echo the command that's being run to the web browser. You can then run the command manually to see if it throws up any errors. I don't think you'll get far with the forward slashes, though...

    EDIT: This script looks like it's trying to run a unix command with it's pipe symbol and stdin. Could this be intended to run on a unix/linux server instead?

    Have you modified this test script at all, and more importantly where did you get it from?
    Quote Quote  
  12. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    First off, I want to thank you for taking the time to help me. I appreciate it, very much.

    I'm not very savvy when it comes to PHP, JavaScript, etc. but I'm learning. I'm putting together a website that is comprised of several different scripts I've found all over the Web. I've gotten everything to work except for being able to convert/stream user uploaded videos.

    The all-in-one script (just like almost all scripts I've found) appears to have been written with NIX based systems in mind. I don't know who authored it. It's the only one that I have not been able to get working. I've posted on several other forums and blogs but I have not received any replies. I've come across very little information for using PHP with ffmpeg/flvtool2 on a Windows/Apache platform.

    I'm thinking my ffmpeg/flvtool2 installs could be the problem. I posted in this forum because I was hoping someone on here is using ffmpeg and flvtool2 on Windows.


    I tried the script in post #11 but I get the following error even when I change the paths. I've tried forward slashes, backslashes, double back slashes and I've even placed the script in the same folder that contains the video file:

    Code:
    Warning: Can't open movie file C:\www\test\clock.avi in C:\www\test\6.php on line 9 Fatal error: Call to a member function getFrameWidth() on a non-object in C:\www\test\6.php on line 11
    I can't remember where I got it but I can't find any that are written specifically for WAMP. I was hoping someone on here had something I could use to test my setup.
    Last edited by jeffshead; 19th Oct 2011 at 16:50.
    Quote Quote  
  13. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    I think I need to get some sleep... The last time I tested the script from post #11 I used the wrong path to the video file, everytime.

    I tested it again, with the correct path and the commands showed on the page and 'clock.flv' was created but it is 0KB.

    Only paths with double back slashes worked.

    Now I need to figure out why the file is 0KB.
    Quote Quote  
  14. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    I'm not very savvy when it comes to PHP, JavaScript, etc. but I'm learning. I'm putting together a website that is comprised of several different scripts I've found all over the Web.
    It's a bit of a learning process for me too. But I've used Apache, PHP, ffmpeg, so it's not all new.

    The all-in-one script (just like almost all scripts I've found) appears to have been written with NIX based systems in mind. I don't know who authored it.

    I've come across very little information for using PHP with ffmpeg/flvtool2 on a Windows/Apache platform. I'm thinking my ffmpeg/flvtool2 installs could be the problem. I posted in this forum because I was hoping someone on here is using ffmpeg and flvtool2 on Windows.
    A lot of the PHP scripts you find online are going to be written with unix/linux in mind. The same is probably true of ffmpeg/flvtool2.

    Originally Posted by jeffshead View Post
    I think I need to get some sleep... The last time I tested the script from post #11 I used the wrong path to the video file, everytime.
    Been there, done that

    I tested it again, with the correct path and the commands showed on the page and 'clock.flv' was created but it is 0KB.

    Now I need to figure out why the file is 0KB.
    I just run a modified version of the code in post #11 to generate a ffmpeg command.

    This is what I'm getting with some dummy data added to the code:
    Code:
    C:\\ffmpeg\\bin\\ffmpeg.exe -i C:\\test\\clock.avi -ar 44100 -ab 128 -f flv -s 640x480 C:\\test\\clock.flv | C:\\flvtool2\\flvtool2.exe -U stdin C:\\test\\clock.flvtool2
    EDIT: to anyone - DON'T bother trying to run this, it contains non valid ffmpeg commands that won't work.


    Can you copy and paste the command in the browser that produces a file of 0KB?

    *On a slightly different topic; You're probably aware of this, but security is an important issue if the code is going to end up on a public website. It really needs to be bulletproof. A business intranet wouldn't be so much of a problem, but you could still have users accidentally doing something wrong and causing grief.

    It's one area that I haven't looked at in detail as all my code to date hasn't ended up online.

    For example, the all-in-one script on page #1 uses the escapeshellcmd() function to sanitise user input and stop someone easily running commands on the webserver. Things like this need to be done as a matter of course.
    Last edited by intracube; 20th Oct 2011 at 23:31.
    Quote Quote  
  15. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    This is what shows on the page when I use your version of the script from post #11. It creates the 0KB 'clock.flv' file:

    Code:
    C:\ffmpeg\bin\ffmpeg.exe -i C:\www\test\clock.avi -ar 8000 -ab 8 -f flv -s 320x320 C:\www\test\clock.flv | C:\flvtool2\flvtool2.exe -U stdin C:\www\test\clock.flv
    I too am concerned about security since it will be a "public" site. However, it will not be indexed (at least not by good bots) and it will require an invite and login to access anything. It's actually a private site I'm putting together for my daughter in an effort to keep her and her friends off of sites like Facebook.
    Quote Quote  
  16. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    I've just been browsing the Flowplayer website, and there might be a much simpler way to do what you're trying to do that works out of the box. Take a look at these links:
    http://flowplayer.org/setup/index.html
    http://flowplayer.org/setup/howto/
    http://flowplayer.org/documentation/index.html

    From the site:
    Any format goes
    Your original video file can be in any format and located on your local hard disk or on a web server. Setup takes care of the file conversion to a web-friendly format. The file is served globally, automatically.

    Flowplayer has moved on a lot since I last looked at it...

    I'll have a better look at it later to see if it actually does what you want, but thought I'd mention it now so you don't spend any more time with the current method.
    Quote Quote  
  17. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Thanks for the Flowplayer tip but I think it will be more work in the long run because I don't think it gives the same functionality, right out of the box, as does the script I'm trying to use.

    I made a little bit more progress. I found another small script I used to test my ffmpeg install. It did successfully convert a couple of test videos.

    PHP Code:
    <?php
     
    convertToFlv
    "1.mp4""test.flv" );
     
    function  
    convertToFlv$input$output ) {
       echo 
    "Converting $input to $output<br  />";
       
    $command "ffmpeg -i $input -s 320x240 -ar 44100 -r 12  $output";
       echo 
    "$command<br />";
       
    shell_exec$command );
        echo 
    "Converted<br />";
    }
    ?>
    The first video I converted has a black screen for the first couple of seconds but the other videos are fine albeit they are skewed because of the 320x240 setting.

    At least I now know my setup can convert videos. Maybe it's just a matter of finding the correct code to use with a Windows setup.
    Quote Quote  
  18. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    Thanks for the Flowplayer tip but I think it will be more work in the long run because I don't think it gives the same functionality, right out of the box, as does the script I'm trying to use.
    While Flowplayer might not do what you want, there might be other ready made solutions that do. Or you could bolt together several solutions.

    Can you give a list of the features you eventually want to have? Have you already got other parts of this site up and running?

    If I'm understanding what you've said so far, you're essentially looking to create a walled garden version of YouTube/Facebook which would include: login page, user accounts, account management, a way to browse/search for videos, comments system, ability for users to delete their own videos, etc. This would be a huge amount of work to write yourself, even if you stitch together pieces of code from various sources.

    It'd be much simpler to modify existing web software to meet your needs. For example, use a free bulletin board system like phpBB, configure it to require an account to access any of the forums, and allow users to add videos to their posts in a similar way to this forum - but the video would be uploaded and converted, rather than just linked to. In addition, Wordpress might give you some other functionality you want.

    I've noticed a number of issues with the code in post #11 which I've modified and can post later. What video player were you planning on using? The existing scripts would give you a h263 .flv file. h264 is a preferred format for streaming these days, and the scripts can be modified to produce this but the video player needs to support it (many do).
    Quote Quote  
  19. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Updated test script:
    PHP Code:
    <?php
    // test encode script v0.32, 2011-10-20

    // Set our source file
     
    $srcFile "C:\\test\\clock.avi";
     
    $destFile "C:\\test\\clock.flv";
     
    $ffmpegPath "C:\\ffmpeg\\bin\\ffmpeg.exe";
     
    $ffmpegPreset "C:\\ffmpeg\\presets\\libx264-medium.ffpreset";
    // Create our FFMPEG-PHP class
     
    $ffmpegObj = new ffmpeg_movie($srcFile);
     
    // Save our needed variables
     
    $srcWidth makeMultipleTwo($ffmpegObj->getFrameWidth());
     
    $srcHeight makeMultipleTwo($ffmpegObj->getFrameHeight());
     
    $srcAspect round($srcWidth $srcHeight2);
     
    $srcFPS $ffmpegObj->getFrameRate();
     
    // Call our convert using exec()
     
    $command "$ffmpegPath -i $srcFile -r $srcFPS -ac 2 -ar 44100 -ab 128k -acodec libmp3lame -vcodec libx264 -fpre $ffmpegPreset -crf 24 -s ${srcWidth}x${srcHeight} -aspect $srcAspect $destFile";
     
    exec($command);
     echo 
    $command;
     
    // Make multiples function
     
    function makeMultipleTwo ($value)
     {
     
    $sType gettype($value/2);
     if(
    $sType == "integer")
     {
     return 
    $value;
     } else {
     return (
    $value-1);
     }
     }
    ?>
    EDIT: now includes path to ffmpeg preset

    I've modified quite a few things and stripped out flvtool2 completely. I can't see that it serves a purpose here.

    If this doesn't work, try copying the code displayed in the browser and run it directly on the server. Post any errors here.
    Last edited by intracube; 20th Oct 2011 at 13:51.
    Quote Quote  
  20. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Does not work from web or directly on server;

    Here is error from commandline:
    Code:
    file for preset 'main' not found
    If I try a different file I get these errors including the one above:
    Code:
    [avi @ 003D9F40] parser not found for codec msrle, packets or times may be inval
    id.
    [avi @ 003D9F40] parser not found for codec truespeech, packets or times may be
    invalid.
    [avi @ 003D9F40] max_analyze_duration 5000000 reached at 5000000
    Quote Quote  
  21. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    You're right about the site being a walled garden version of YouTube/Facebook. Actually, the site is pretty much complete except for being able to upload/stream user videos and changing the look of the site.

    The script in post #11 is not part of the all-in-one script. It was something I found and used only to test ffmpeg since I did not know if the issues were caused by my ffmpeg install or the all-in-one script.

    I was hoping that the all-in-one script just needed some simple path tweaking. It uploads the videos into the temp folder and renames them but they just sit there. The encode, thumbnail creation and moving of the file never happens. I can't find any mention of a cron job being needed. I really think the issue is with it being made for NIX but I have no clue about what to change and I have found very little information about scripts for ffmpeg on WAMP.

    I very rarely consider "throwing in the towel" but this one has really got me stumped

    I've attached the script's PHP files if you care to have a look.
    Image Attached Files
    Last edited by jeffshead; 20th Oct 2011 at 13:47.
    Quote Quote  
  22. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    Does not work from web or directly on server;

    Here is error from commandline:
    Code:
    file for preset 'main' not found
    I was half expecting you to get that error. FFmpeg supports presets where many of the encoding parameters can be defined. Seems that the windows version of FFmpeg still doesn't come bundled with them. Download the attachment in this post, create a 'presets' folder (all lowercase) in C:\ffmpeg\ and place the file in there.

    If I try a different file I get these errors including the one above:
    Stick to the original video for now to avoid introducing another variable.

    EDIT: I'm having trouble uploading the preset as an attachment I'll ask one of the forum mods.

    I've modified the code in post #19 to work with the preset, but hold off doing anything until I can upload this file.
    Quote Quote  
  23. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Still can't upload the file. Instead, copy and paste the text into nodepad and save as libx264-medium.ffpreset in:
    C:\ffmpeg\presets\
    Code:
    coder=1
    flags=+loop
    cmp=+chroma
    partitions=+parti8x8+parti4x4+partp8x8+partb8x8
    me_method=hex
    subq=7
    me_range=16
    g=250
    keyint_min=25
    sc_threshold=40
    i_qfactor=0.71
    b_strategy=1
    qcomp=0.6
    qmin=10
    qmax=51
    qdiff=4
    bf=3
    refs=3
    directpred=1
    trellis=1
    flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
    wpredp=2
    Quote Quote  
  24. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    That works. I was able to convert two different files
    Quote Quote  
  25. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jeffshead View Post
    That works. I was able to convert two different files
    Great. Give it a test with as many varied file formats as you've got; different framerates/aspect ratios/sizes/codecs/etc.

    There's obviously a lot of room for refinement with the script. Limiting the resolution is one idea that comes to mind. If a user uploads an HD 1920x1080, the script will spit out a file at that res, so you might want to define a maximum resolution somewhere.
    Quote Quote  
  26. Member
    Join Date
    Dec 2011
    Location
    puducherry
    Search Comp PM
    plz post last used code
    Quote Quote  
  27. Member jeffshead's Avatar
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Originally Posted by velayudham View Post
    plz post last used code
    The last code I used to successfully convert files is in post #23.

    After spending day after day searching for answers, I finally gave up on trying to make the original script work work for WAMP. The script was designed to work on LAMP and I could not find anyone that knows why it works on LAMP but not WAMP. This is actually the second time in 2-3 years that I've tried to get this script fully functional on WAMP. The script is fully functional otherwise.
    Quote Quote  



Similar Threads