VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member
    Join Date
    Jun 2011
    Location
    London
    Search Comp PM
    Hi

    I am trying to convert videos in some format into flv using ffmpeg. The converted video that is create is 0 kb. I need some help to get it working thanks.

    This is the code:

    <?Php


    function makeMultipleTwo ($value){
    $sType = gettype($value/2);
    if($sType == "integer"){
    return $value;
    } else {
    return ($value-1);
    }
    }

    $srcFile = "Videos/robot.avi";
    $destFile = "Videos/robot.flv";
    $ffmpegPath = "ffmpeg";
    $flvtool2Path = "flvtool2";


    $ffmpegObj = new ffmpeg_movie($srcFile);


    $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
    $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
    $srcFPS = $ffmpegObj->getFrameRate();
    $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
    $srcAR = $ffmpegObj->getAudioSampleRate();


    $command = $ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile;
    $convert = exec($command);



    if(!$convert){
    echo "FAILED!!!";
    }

    ?>

    I must say I do not have flvtools on my server but I guess it does not matter as flvtools is only used for getting meta data.

    Thanks.
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Output the $command and try it manually from the command line and see if any error message.
    Quote Quote  
  3. Member
    Join Date
    Jun 2011
    Location
    London
    Search Comp PM
    Hi thanks for the reply.

    I do not think I can do it because my ffmpeg is running on a hosting company server. How would I manually run it from a command line to get an error.

    Thanks.
    Quote Quote  
  4. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Start with print the $command and post it here.
    Quote Quote  
  5. Member
    Join Date
    Jun 2011
    Location
    London
    Search Comp PM
    Hi

    ERROR: /usr/bin/flvtool2:2

    This is the error I recieve like I said I dont have flvtool on my server plan but did not think it matter as its only used for meta data.
    I also do not know how to modify my code not to include flvtools in the command.

    Hope you can help:

    Thanks
    Quote Quote  
  6. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by Tonybot View Post
    I also do not know how to modify my code not to include flvtools in the command.
    The obvious thing to try is to replace
    PHP Code:
    $command $ffmpegPath " -i " $srcFile " -ar " $srcAR " -ab " $srcAB " -f flv -s " $srcWidth "x" $srcHeight " " $destFile " | " $flvtool2Path " -U stdin " $destFile
    by (removing the second part):
    PHP Code:
    $command $ffmpegPath " -i " $srcFile " -ar " $srcAR " -ab " $srcAB " -f flv -s " $srcWidth "x" $srcHeight " " $destFile
    Quote Quote  
  7. Member
    Join Date
    Jun 2011
    Location
    London
    Search Comp PM
    Hi I modified the code as you said, but for some reason the code does not convert any thing and no error is printed out before the file would convert but have 0kb.
    this is the code.



    function makeMultipleTwo ($value){
    $sType = gettype($value/2);
    if($sType == "integer"){
    return $value;
    } else {
    return ($value-1);
    }
    }

    $srcFile = "Videos/robot.avi";
    $destFile = "Videos/robot.flv";
    $ffmpegPath = "ffmpeg";



    $ffmpegObj = new ffmpeg_movie($srcFile);


    $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
    $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
    $srcFPS = $ffmpegObj->getFrameRate();
    $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
    $srcAR = $ffmpegObj->getAudioSampleRate();



    $command = $ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile;
    $convert = exec($command);



    if(!$convert){
    echo "FAILED!!!";
    }

    print_r($convert);
    Last edited by Tonybot; 7th Jun 2011 at 04:56.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!