![]()
Let's check the metadata just to make sure we got the rotation right: exiftool -Rotation -ImageWidth -ImageHeight temp.mp4 Rotation : 0 You might notice the thumbnail of the newly generated video is rotated. However, the width and height are still the wrong way round. This will create a copy of the video and reset the rotation metadata to 0. HOW TO USE FFMPEG IN PHP SOFTWARETo fix the video rotation so it is compatible with the widest range of software and viewing applications we will need to reset the rotation and then swap around the width and height.įirst we need to reset the rotation to 0: ffmpeg -i h1920_w1080_f30_a9-16_r90.mp4 -c copy -metadata:s:v:0 rotate = 0 temp.mp4 We'll get rotation = 90 and width = 1920 Fix video rotation using FFmpeg To retrieve the width: ffprobe -v error -select_streams v:0 -show_entries stream =width -of default =nw = 1:nk = 1 -i h1920_w1080_f30_a9-16_r90.mp4 To retrieve just the rotation: ffprobe -v error -select_streams v:0 -show_entries stream_tags =rotate -of default =nw = 1:nk = 1 -i h1920_w1080_f30_a9-16_r90.mp4 To filter the FFprobe info we can use different commands: It analyzes the video metadata and prints the information in human readable format ffprobe -i h1920_w1080_f30_a9-16_r90.mp4 Get video rotation metadata using FFprobe or FFmpegįFprobe is an utility that comes bundled with FFmpeg. The output confirms what we described - the rotation is 90 and the width and height are switched: Rotation : 90īecause the video is shot in vertical mode, we would expect the width to be 1080 and the height, 1920 pixels. Or all at once: exiftool -Rotation -ImageWidth -ImageHeight h1920_w1080_f30_a9-16_r90.mp4 You can pass them individually: exiftool -Rotation h1920_w1080_f30_a9-16_r90.mp4 We only need to retrieve the rotation and the dimensions, so we can pass the -Rotation, -ImageWidth and -ImageHeight options. This command will return all metadata from the video file. Get rotated video metadata using ExifTool exiftool h1920_w1080_f30_a9-16_r90.mp4 HOW TO USE FFMPEG IN PHP FOR FREEWe prepared a few sample videos if you want to experiment using different video rotations - please check the Test Media repository for free to use samples.įor this article we used the h1920_w1080_f30_a9-16_r90.mp4 video, which was shot using a Samsung S9 Android device in vertical, portrait orientation.įirst let's take a look at the metadata of the video we want to fix. ExifTool is a free and open-source program for reading and modifying metadata and exif information. This guide covers Windows, Mac and Linux distributions - the apps we'll use are platform independent.įFmpeg is the leading multimedia framework used to manipulate and transform video files easily. HOW TO USE FFMPEG IN PHP HOW TOThis tutorial will show you how to use FFmpeg to rotate videos and get the right orientation, width and height with just a couple of commands. However, it's not only the rotation that needs to be fixed, it's also the width and height of the video that needs to be adjusted as these can also be he wrong way round. It has 4 possible values (0, 90, 180 and 270) and it stores how the device was held when starting the recording: In this article we'll focus on the rotation - it represents the orientation of the device. Videos and images created by mobile devices including iPhones and Android phones contain a lot of metadata like GPS position, device make and model, fps, rotation and many others. ![]() Video rotation is one tricky, but simple issue to overcome and in this guide we will show you how to fix rotated videos using FFMpeg. HOW TO USE FFMPEG IN PHP UPDATEThis might also happen if you start recording in one orientation and then rotate the smartphone before the device has a chance to update it's orientation settings. Depending on the software or app you're using to edit, preview or share, the videos might appear rotated or even upside down. ![]() Quite often, when using a smartphone, we shoot videos in portrait mode, also known as vertical video, or even rotated 180 degrees. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |