php怎么用ffmpeg.exe动态截图

 我来答
好程序员
2016-12-08 · HTML5前端培训/大数据培训/Java
好程序员
好程序员是IT高端课程培训基地,从平凡到卓越,为梦想而拼搏。
向TA提问
展开全部
$movie = new ffmpeg_movie('4.mp4');
$width=$movie->getFrameWidth();
$height=$movie->getFrameHeight();
$count= $movie->getFrameCount();
print $count . '';
$n = round ( $count/16 );
print $n . '';
for ( $i = 1; $i <= 1; $i ++ ) {
$img = 'screencap' . $i . '.png';
$x = $n * $i;
$f = $movie->getFrame($x);
$gd_image = $f->toGDImage();
imagepng($gd_image, $img);
imagedestroy($gd_image);
echo "
\n";
}
$extension = "ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
// load extension
if (!extension_loaded($extension)) {
dl($extension_soname) or die("Can't load extension $extension_fullname\n");
}
if (php_sapi_name() != 'cli') {
echo '
';
}
printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
printf("ffmpeg-php build date string: %s\n", FFMPEG_PHP_BUILD_DATE_STRING);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
print_class_methods("ffmpeg_movie");
print_class_methods("ffmpeg_frame");
// get an array for movies from the test media directory
$movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
echo "--------------------\n\n";
foreach($movies as $movie) {
$mov = new ffmpeg_movie($movie);
printf("file name = %s\n", $mov->getFileName());
printf("duration = %s seconds\n", $mov->getDuration());
printf("frame count = %s\n", $mov->getFrameCount());
printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
printf("comment = %s\n", $mov->getComment());
printf("title = %s\n", $mov->getTitle());
printf("author = %s\n", $mov->getAuthor());
printf("copyright = %s\n", $mov->getCopyright());
printf("get bit rate = %d\n", $mov->getBitRate());
printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
if ($mov->hasAudio()) {
printf("get audio stream id= %s\n", $mov->getAudioStreamId());
printf("get audio codec = %s\n", $mov->getAudioCodec());
printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
printf("get audio channels = %s\n", $mov->getAudioChannels());
}
printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
if ($mov->hasVideo()) {
printf("frame height = %d pixels\n", $mov->getFrameHeight());
printf("frame width = %d pixels\n", $mov->getFrameWidth());
printf("get video stream id= %s\n", $mov->getVideoStreamId());
printf("get video codec = %s\n", $mov->getVideoCodec());
printf("get video bit rate = %d\n", $mov->getVideoBitRate());
printf("get pixel format = %s\n", $mov->getPixelFormat());
printf("get pixel aspect ratio = %s\n", $mov->getPixelAspectRatio());
$frame = $mov->getFrame(10);
printf("get frame = %s\n", is_object($frame) ? 'true' : 'false');
printf(" get frame number = %d\n", $mov->getFrameNumber());
printf(" get frame width = %d\n", $frame->getWidth());
printf(" get frame height = %d\n", $frame->getHeight());
}
echo "\n--------------------\n\n";
}
if (php_sapi_name() != 'cli') {
echo '';
}
/* FUNCTIONS */
function print_class_methods($class) {
echo "\nMethods available in class '$class':\n";
$methods = get_class_methods($class);
if (is_array($methods)) {
foreach($methods as $method) {
echo $method . "\n";
}
} else {
echo "No Methods Defined\n";
}
}
function getDirFiles($dirPath)
{
if ($handle = opendir($dirPath))
{
while (false !== ($file = readdir($handle))) {
$fullpath = $dirPath . '/' . $file;
if (!is_dir($fullpath) && $file != "CVS" && $file != "." && $file != "..")
$filesArr[] = trim($fullpath);
}
closedir($handle);
}
return $filesArr;
}
?>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式