Maison > Article > développement back-end > windows下ffmpeg-php装配
windows下ffmpeg-php安装
工作用到获取视频时长,需要在windows下扩展ffmpeg
在网上找的全是支持32位的系统,我是64位win7的 php版本为5.2.4
下载32位下包http://download.csdn.net/detail/xiao_bai8/7027699,打开有avcodec-51.dll、avformat-51.dll、avutil-49.dll、pthreadGC2.dll、php_ffmpeg.dll
把php_ffmpeg.dll还是放到php/ext下
剩下的四个文件放到C:\Windows\SysWOW64下,之前是放到C:\Windows\System32,但是64位没反映
代码测试:
<?php extension_loaded('ffmpeg'); $ffmpegInstance = new ffmpeg_movie('C:\wamp\www\top10.mp4');echo "getDuration: " . $ffmpegInstance->getDuration()."<br>" ."getFrameCount: " . $ffmpegInstance->getFrameCount()."<br>" ."getFrameRate: " . $ffmpegInstance->getFrameRate()."<br>" ."getFilename: " . $ffmpegInstance->getFilename()."<br>" ."getComment: " . $ffmpegInstance->getComment()."<br>" ."getTitle: " . $ffmpegInstance->getTitle()."<br>" ."getAuthor: " . $ffmpegInstance->getAuthor()."<br>" ."getCopyright: " . $ffmpegInstance->getCopyright()."<br>" ."getArtist: " . $ffmpegInstance->getArtist()."<br>" ."getGenre: " . $ffmpegInstance->getGenre()."<br>" ."getTrackNumber: " . $ffmpegInstance->getTrackNumber()."<br>" ."getYear: " . $ffmpegInstance->getYear()."<br>" ."getFrameHeight: " . $ffmpegInstance->getFrameHeight()."<br>" ."getFrameWidth: " . $ffmpegInstance->getFrameWidth()."<br>" ."getPixelFormat: " . $ffmpegInstance->getPixelFormat()."<br>" ."getBitRate: " . $ffmpegInstance->getBitRate()."<br>" ."getVideoBitRate: " . $ffmpegInstance->getVideoBitRate()."<br>" ."getAudioBitRate: " . $ffmpegInstance->getAudioBitRate()."<br>" ."getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate()."<br>" ."getVideoCodec: " . $ffmpegInstance->getVideoCodec()."<br>" ."getAudioCodec: " . $ffmpegInstance->getAudioCodec()."<br>" ."getAudioChannels: " . $ffmpegInstance->getAudioChannels()."<br>" ."hasAudio: " . $ffmpegInstance->hasAudio(); 7.执行后如果拿到视频的一些信息如下就表示环境配置成功了,那我们就可以开始开发我们的视频转换了。 执行结果: getDuration: 811.13336181641<span style="white-space:pre"> </span>//时长getFrameCount: 12167<span style="white-space:pre"> </span>//帧计数getFrameRate: 15<span style="white-space:pre"> </span>//帧速率getFilename: C:\wamp\www\top10.mp4<span style="white-space:pre"> </span>//文件名路径getComment:<span style="white-space:pre"> </span>//评论getTitle:getAuthor:getCopyright:getArtist:getGenre:getTrackNumber: 0getYear: 0getFrameHeight: 240getFrameWidth: 320getPixelFormat: yuv420p<span style="white-space:pre"> </span>//像素格式getBitRate: 269769<span style="white-space:pre"> </span>//比特率getVideoBitRate:getAudioBitRate:getAudioSampleRate: 48000getVideoCodec: mpeg4<span style="white-space:pre"> </span>//视频编解码器getAudioCodec: mpeg4aacgetAudioChannels: 2hasAudio: 1