doujiao2443 2012-11-10 02:25
浏览 107
已采纳

ffmpeg:如何获取PHP的可用编解码器列表?

Problem is, I am trying to convert (through php), a .3gp (or any video format) file to ogg.

When I do not specify -vcodec and -acodec, the video is converted, but does not have any audio.

I had read here and other places that I need to specify -acodec libvorbis, however, when I specify the codec as libvorbis, the conversion fails: video converts to 0byte file.

Basically, I am trying to determine if the codec specified is actually part of the ffmpeg build I am using as a process of narrowing down my issue.

Code that produces full length video without sound:

$srcFile = 'anyvideo.3gp';
$destFile = 'anyvideo.ogg';
$ffmpegPath = 'path/to/ffmpeg.exe';
$ffmpegObj = new ffmpeg_movie($srcFile);
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth()); 
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate(); 
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
$srcLen = $ffmpegObj->getDuration();

exec($ffmpegPath." -i ".$srcFile." -ar ".$srcAR." -s ".$srcWidth."x".$srcHeight." ". $destFile);

And the code that produces 0byte file:

exec($ffmpegPath." -i ".$srcFile." -acodec libvorbis -ar ".$srcAR." -s ".$srcWidth."x".$srcHeight." ".$destFile);

So, my question is, how do I determine the codec's available to ffmpeg using PHP? Can it even be done?

UPDATED - ANSWER BELOW

  • 写回答

3条回答 默认 最新

  • dongna2498 2012-11-19 01:02
    关注

    ANSWER:

    exec($ffmpegPath." -codecs", $codecArr);
    for($ii=0,$ii<count($codecArr);$ii++){
        echo $codecArr[$ii];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 webAPI接口返回值判断
  • ¥15 自动化测试 UI Automtion
  • ¥20 关于#深度学习#的问题:2708)输出:邻接矩阵A 或者 节点索引方式:通过随机游走或者其他方式,保持节点连接类似下图(语言-python)
  • ¥15 win2012 iscsi ipsec
  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?