开发者

php library for ffmpeg video processing?

I have installed ffmpeg on my server.

Now I am looking for a php library which can perform ffmpeg functionality, like retrieving 开发者_StackOverflow中文版video information, converting it to FLV or in any other format, and streaming video.

Please help, Thanks!


You can use below function to convert mp4 video to flv

function mp4toflv($in, $out)
{
    //echo $in.'  '.$out;
    $thumb_stdout;
    $errors;
    $retval = 0;


    // Delete the file if it already exists
    if (file_exists($out)) { unlink($out); }
    $cmd  = "ffmpeg -i $in -ar 22050 -acodec libmp3lame -ab 32K -r 25 -s 320x240 -vcodec flv $out";

    //$cmd = "ffmpeg -i $in -b 1024k -s 352x264 -r 25 -acodec copy $out";
    //echo escapeshellcmd($cmd);
        exec(escapeshellcmd($cmd));
    unlink($in); 

}

similarly you can also convert other video formats to flv or any other format. Below are some help to convert videos to mp4(h264)

1]. ffmpeg -i input.mp4 -vcodec libx264 output.mp4
2]. ffmpeg input.AVI -vcodec libx264 -sameq output.mp4

option 1 can use for :- (mp4,mov,flv) option 2 can user for :- (3gp,avi,mp4,mov,flv)

execute above commands using "exec(escapeshellcmd($cmd))" where $cmd will be any from above two options.

Hope this will help someone :)


We have been using ffmpeg-php without any major problems, just make sure you are using supported ffmpeg version. If you need any special behaviour, you can always additionally wrap it using exec().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜