php应用程序中的FFMPEG缩略图没有正确旋转 [英] FFMPEG thumbnail in php application's is not rotated properly
本文介绍了php应用程序中的FFMPEG缩略图没有正确旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在php应用程序中创建了一个FFMPEG缩略图,并尝试旋转缩略图,如果视频是从底部(反向),但图像旋转不能正常工作。
以下是图像旋转的代码
I have created a FFMPEG thumbnail in a php application and tried to rotate the thumbnail image if the video is bottom up(reversed).But the image rotate is not working properly. The below is the code for image rotation
$video = $storeHere.$mediaFile;
$tImage = $upload_output['uploaded_file'].'.jpg';
$thumbnail = $storeHere.$tImage;
// shell command [highly simplified, please don't run it plain on your script!]
shell_exec("ffmpeg -i $video -deinterlace -an -ss 1 -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg -s 250x250 $thumbnail 2>&1");
/* image rotate fix */
$source = imagecreatefromjpeg($thumbnail);
$degrees = 270;
$rotate = imagerotate($source, $degrees, 0);
imagejpeg($rotate,$thumbnail);
/* rotate fix ends */
推荐答案
HI我找到了这个解决方案,
HI I have found the solution for this one,
shell_exec("ffmpeg -i $video -deinterlace -an -ss 1 -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg -s 250x250 $thumbnail 2>&1");
/* image rotate fix *///vignesh
$exif = exif_read_data($thumbnail);
if (!empty($exif['Orientation'])) {
$source = imagecreatefromjpeg($thumbnail);
switch ($exif['Orientation']) {
case 3:
$degrees = 180;
break;
case 6:
$degrees = -90;
break;
case 8:
$degrees = 90;
break;
}
$rotate = imagerotate($source, $degrees, 0);
imagejpeg($rotate,$thumbnail);
这篇关于php应用程序中的FFMPEG缩略图没有正确旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文