FFMPEG thumbnail in php application does not rotate properly

I created an FFMPEG thumbnail in a php application and tried to rotate the thumbnail if the snapshot is from bottom to top (reverse). But image rotation does not work properly. Below is the image rotation code

$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
source share
2 answers

HI I found a solution for this,

 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);
0
source

, , .
, , ,
, API- Native () , play() it - longtailvideo.com/support/jw-player/31800/loading-new-playlists, , , .

+1

Source: https://habr.com/ru/post/1620536/


All Articles