www.webdeveloper.com
Results 1 to 5 of 5

Thread: php and ffmpeg questions

  1. #1
    Join Date
    Nov 2011
    Posts
    37

    php and ffmpeg questions

    Hello everyone,

    I am working on a project that allows users to upload video. For accessibility purpose, I need to convert the video file to .mp4, .ogv and .webm.

    So the idea is to use:

    1. input file to allow user to upload.

    2. After upload is completed, the php script will call 3 commands(I am planning to use shell_exec() to call these 3 commands).

    ffmpeg -i video.avi video.ogv
    ffmpeg -i video.avi video.ogv
    ffmpeg -i video.avi video.ogv



    My questions are:

    1. Am I doing it right? I ve seen a php extension call php_ffmpeg. Not sure if I can use it to achieve my goal instead.

    2. If I proceed to do those things above, Will there be a problem if I try to call those 3 commands at the same time? Will they even be executed? It takes a while for me to convert a small video by using the command prompt.

  2. #2
    Join Date
    Jan 2011
    Location
    Canada
    Posts
    125
    For starters, you will probably have to point php to your ffmpeg install. Not sure where that would be on a windows system, but in linux, you would use something like
    PHP Code:
    $ffmpeg "/usr/local/bin/ffmpeg"
    Then to actually execute your conversion, use something like
    PHP Code:
    $exec_string = ($ffmpeg " -i " $uploadFilename" -b:v 2000k -acodec libvorbis -ac 2 -ab 256k -threads 0 " $finout "");
       
    exec($exec_string); 
    Obviously, you need to set the variables for the original file name ($uploadFilename) and the name of your newly created output file ($finout). But that works for me. And depending on how you installed ffmpeg, you may find that you need to reinstall it. There are a variety of addons/extra codecs. For myself, I found the basic ffmpeg install would have issues with webm. I needed to install it with additional codecs activated.

    There's a good tutorial for that here
    https://ffmpeg.org/trac/ffmpeg/wiki/...mpilationGuide

    Be sure to follow all the "optional" steps as well.

  3. #3
    Join Date
    Jan 2011
    Location
    Canada
    Posts
    125
    And it won't run them all at once. It will do it sequentially.

  4. #4
    Join Date
    Nov 2011
    Posts
    37
    Thank you.

  5. #5
    Join Date
    Nov 2011
    Posts
    37
    neither exec or shell_exec can execute command prompt commands. They are meant to call shell script commands only I guess. Will need to install linux.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles