PHP从FLV文件获取视频预览图的方法

本文实例讲述了PHP从FLV文件获取视频预览图的方法分享给大家供大家参考。具体实现方法如下:

代码如下:
&1"); $duration = ob_get_contents(); ob_end_clean(); // debug ("Duration: ",$duration); preg_match('/Duration: (.*?),/',$duration,$matches); $duration = $matches[1]; // debug ("Duration: ",$duration); $duration_array = split(':',$duration); $duration = $duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2]; $time = $duration * $percent / 100; // debug (" Time: ",$time); $time = intval($time/3600) . ":" . intval(($time-(intval($time/3600)*3600))/60) . ":" . sprintf("%01.3f",($time-(intval($time/60)*60))); // debug (" Time: ",$time); } $browser = (isset($_GET['browser'])) ? strval($_GET['browser']) : 'true'; // debug (" browser: ",$browser); if ($browser == "true") { header('Content-Type: image/png'); exec("/usr/bin/ffmpeg -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -"); //header('Content-Type: image/jpeg'); //exec("/usr/bin/ffmpeg -vcodec mjpeg -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -"); } else { exec("/usr/bin/ffmpeg -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 \"" . $image . "\"%d.png"); //exec("/usr/bin/ffmpeg -vcodec mjpeg -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 \"" . $image . "\"%d.jpg"); } ?>

希望本文所述对大家的PHP程序设计有所帮助。

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...