问题
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 */
回答1:
The above solution still may have an issue of the video to be played every time to generate the thumbnail.
the simplest way i guess is to use the native player in your mobile to play the video
What you could do is try to use Native player API to load() content, then play() it - longtailvideo.com/support/jw-player/31800/loading-new-playlists, however, there needs to be a player instance already present on the page first for this to work.
回答2:
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);
来源:https://stackoverflow.com/questions/31759302/ffmpeg-thumbnail-in-php-applications-is-not-rotated-properly