ffmpeg生成正确旋转的缩略图?

时间:2015-10-31 17:57:22

标签: php ffmpeg

我在php中运行ffmpeg命令服务器端。首先将上传的文件转换为.mp4,然后从文件生成缩略图。问题是由于视频元数据中的旋转标记,缩略图会旋转。如何将此旋转标记添加到生成的缩略图中,以便缩略图也正确定位?

        $getFromSecond = 5;
        $videoFile = $video_base . $_FILES['media']['name'];
        $pos = strpos($videoFile, '.');
        $videoFileName = substr($videoFile, 0, $pos);
        $videoFileName = $videoFileName . ".mp4";

        $cmd_convert = "$ffmpeg -i $videoFile -map_metadata 0 -vcodec copy -acodec copy -y $videoFileName && rm $videoFile";
        exec($cmd_convert);

        $imageFile = $thumb_base . $thumb_name[0] . '.jpg';
        $size='400x300';            

        $cmd_thumb = "$ffmpeg -i $videoFileName -an -ss $getFromSecond -s $size $imageFile";
        exec($cmd_thumb);

0 个答案:

没有答案