当前位置:首页 » 编程语言 » php动图

php动图

发布时间: 2025-02-10 17:01:10

1. php怎么用ffmpeg.exe动态截图

$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("ration = %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("right = %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;
}
?>

2. php如何下载动态图片保存到本地

php 远程下载文件

function http($url, $file="", $timeout=60) {
$file = empty($file) ? pathinfo($url,PATHINFO_BASENAME) : $file;
$dir = pathinfo($file,PATHINFO_DIRNAME);
!is_dir($dir) && @mkdir($dir,0755,true);
$url = str_replace(" ","%20",$url);

if(function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$temp = curl_exec($ch);
if(@file_put_contents($file, $temp) && !curl_error($ch)) {
return $file;
} else {
return false;
}
} else {
$opts = array(
"http"=>array(
"method"=>"GET",
"header"=>"",
"timeout"=>$timeout)
);
$context = stream_context_create($opts);
if(@($url, $file, $context)) {
//$http_response_header
return $file;
} else {
return false;
}
}
}

3. php迅速做简单的动态网站( 只需要 能够在后台更新文字和图片)

这们朋友,你要实现更新文字和图片功能,需要有知道以下知识点:
1)数据库的增删改查操作;

2)使用PHP对数据库进行操作(涉及到表单提交);
3)用PHP使结果循环遍历输出;
4)分页功能实现;
5)文件上传(主要针对图片更新)
以上几点你只要会了,你所说的功能就可以简单实现。当然,还有个笨办法,就是你做静态网页,要添加的内容可以用DW的可视化编辑添加好内容然后上传到服务器后做好相关链接,这样就不涉及到数据库操作,也不用PHP,只是每次更新的内容只存在静态网页中,无法保存到数据库里。两者你可以任选其一了。
(Mekbo【麦客博】)

4. php 如何让gif动图转换为gif静图

以下是一个缩略图生成程序,我加了注释,动态gif动画处理后就变成静态了,程序还可以加水印,当然传参你留空就不会加了。使用有困难的话给我留言。
-----------------------------
/*构造函数-生成缩略图+水印,参数说明:$srcFile-图片文件名,$dstFile-另存文件名,$markwords-水印文字,$markimage-水印图片,$dstW-图片保存宽度,$dstH-图片保存高度,$rate-图片保存品质*/
function makethumb($srcFile,$dstFile,$dstW,$dstH,$rate=100,$markwords=null,$markimage=null)
{
$data = GetImageSize($srcFile);
switch($data[2])
{
case 1:
$im=@ImageCreateFromGIF($srcFile);
break;
case 2:
$im=@ImageCreateFromJPEG($srcFile);
break;
case 3:
$im=@ImageCreateFromPNG($srcFile);
break;
}
if(!$im) return False;
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$dstX=0;
$dstY=0;
if ($srcW*$dstH>$srcH*$dstW)
{
$fdstH = round($srcH*$dstW/$srcW);
$dstY = floor(($dstH-$fdstH)/2);
$fdstW = $dstW;
}
else
{
$fdstW = round($srcW*$dstH/$srcH);
$dstX = floor(($dstW-$fdstW)/2);
$fdstH = $dstH;
}
$ni=ImageCreateTrueColor($dstW,$dstH);
$dstX=($dstX<0)?0:$dstX;
$dstY=($dstX<0)?0:$dstY;
$dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX;
$dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY;
$white = ImageColorAllocate($ni,255,255,255);
$black = ImageColorAllocate($ni,0,0,0);
imagefilledrectangle($ni,0,0,$dstW,$dstH,$white);// 填充背景色
ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH);
if($markwords!=null)
{
$markwords=iconv("gb2312","UTF-8",$markwords);
//转换文字编码
ImageTTFText($ni,20,30,450,560,$black,"simhei.ttf",$markwords); //写入文字水印
//参数依次为,文字大小|偏转度|横坐标|纵坐标|文字颜色|文字类型|文字内容
}
elseif($markimage!=null)
{
$wimage_data = GetImageSize($markimage);
switch($wimage_data[2])
{
case 1:
$wimage=@ImageCreateFromGIF($markimage);
break;
case 2:
$wimage=@ImageCreateFromJPEG($markimage);
break;
case 3:
$wimage=@ImageCreateFromPNG($markimage);
break;
}
image($ni,$wimage,500,560,0,0,88,31); //写入图片水印,水印图片大小默认为88*31
imagedestroy($wimage);
}
ImageJpeg($ni,$dstFile,$rate);
ImageJpeg($ni,$srcFile,$rate);
imagedestroy($im);
imagedestroy($ni);
}
?>

热点内容
h板电影种子ftp 发布:2025-02-11 09:06:10 浏览:738
c语言数据类型定义 发布:2025-02-11 09:00:38 浏览:237
一个小时如何选择服务器 发布:2025-02-11 08:58:14 浏览:442
网易我的世界服务器推荐国服 发布:2025-02-11 08:56:34 浏览:241
电视父母锁屏密码应该会是什么 发布:2025-02-11 08:36:42 浏览:892
梅花适合用哪些植物进行配置 发布:2025-02-11 08:30:54 浏览:252
安卓手机如何像苹果一样弹窗 发布:2025-02-11 08:26:33 浏览:912
压缩文件扫码 发布:2025-02-11 08:20:55 浏览:258
小米5安卓70怎么分屏 发布:2025-02-11 08:00:58 浏览:140
访问二维码 发布:2025-02-11 08:00:11 浏览:883