3

ビデオを HTML5 ビデオと互換性のある形式に変換するために、次のスクリプトを作成しました。

    $srcFile = "name/of/the/video.mp4";
    $destFile = "/media/video/newfilename";
    $ffmpegPath = "/usr/local/bin/ffmpeg";
    $flvtool2Path = "/usr/local/bin/flvtool2";

    // 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();
    $srcVB = floor($ffmpegObj->getVideoBitRate()/1000); 


    // Call our convert using exec() to convert to the three file types needed by HTML5
    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libx264 -vpre hq -vpre ipod640 -b ".$srcVB."k -bt 100k -acodec libfaac -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".mp4");

    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libvpx -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . " -ac 2 -f webm -g 30 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".webm");

    exec($ffmpegPath . " -i ". $srcFile ." -vcodec libtheora -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".ogv");

入力ビデオ タイプを取り、それを mp4、ogv、および webm に変換することになっています。.mov ファイルでスクリプトを実行すると、mp4 および ogv ファイルが返されますが、webm は返されません。.mp4 ファイルで実行すると、変換されたファイルがまったく返されません。ファイルを変換する方法に何か問題がありますか? 何か助けはありますか?

4

1 に答える 1

0

コマンドラインでCMDを実行して何が問題なのかを確認するか、phpコードで各EXECの変数の末尾を追加することができます

exec($ffmpegPath . " -i ". $srcFile ." -vcodec libx264 -vpre hq -vpre ipod640 -b ".$srcVB."k -bt 100k -acodec libfaac -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".mp4" , $VARIABLE );

var_dump($VARIABLE);

そして、あなたが得るエラーの種類を見てください:)

于 2011-12-11T00:31:37.820 に答える