-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotation may need an overhaul #322
Comments
So, is it going to be fixed? Alan |
+1 for this. have noticed this issue as well using phone footage. Have been fixing the source video using FFMpeg for the time being but something in libopenshot to handle this would be good. Be interesting to know how efficient it would be however. With ffmpeg I need to re-encode to fix the issue. Something like this:
First line resets the rotation but as mentioned the width/height is still the wrong way round. Second line rotates the video correctly with the correct width/height. |
Yeah, the efficiency question is a good one, I think it all comes down to when and how the rotation is done. The argument for not "pre-applying" rotation to input Frames (effectively, doing the internal equivalent of your reencoding), is that eventually in the course of processing frame images a Writer is going to use Regardless when the rotation is applied, combining intrinsic rotation and user rotation (as we're currently doing) isn't really a good idea. When an input video contains intrinsic rotation, we want to also rotate its frame dimensions so that we can apply proper scaling. When the user rotates a frame with keyframe rotation, we want that to happen after scaling without having any effect on the size. (Otherwise, a rotating video in Best Fit mode would change size based on how its bounding box's dimensions changed from frame to frame.) So, it really needs to go:
Delaying rotation until outputAs I said, to be most efficient that entire list would be done all at once, while painting each frame into its output image. It might even be possible to compute steps 1-3 a single time in But if we do that...
...Plus any other issues I haven't thought of. There could definitely be more than what's here. Even if this is a complete list, though... given all the complexity involved, maybe we're better off just taking the hit on efficiency by building each Frame with the intrinsic rotation already applied. |
Thorough explanation. Doesn't sound like a simple task. |
Given the issues reported in OpenShot/openshot-qt#2969 (and others), and based on my own tests, it seems like the current rotation support in OpenShot is... insufficient.
The problem arises when you have a video rotated in a way that changes its dimensions (which, you know, is most rotation effectively, except for 0° and 180°.) Because libopenshot still processes the video as though it has the
width
andheight
of its original dimensions, things don't go well.This can be seen by creating a vertical video profile, then importing a video in true vertical aspect, vs. a video with standard wide aspect and an initial rotation. The true-upright video loads in just fine, and formats correctly to the output frame. The rotated widescreen video is loaded shrunken down (with "Best Fit" scaling) in the center of the output frame, only about half of its full size. This seems to be because libopenshot is scaling it as if it needs to fit a
1920px
wide image inside a1080px
wide frame.My guess is that what's missing, for starters, is a post-rotation coordinate mapping of the QTransform:
libopenshot/src/Timeline.cpp
Lines 553 to 566 in f8c180c
QTransform has all sorts of
map()
andmapRect()
functions to translate spatial data into the transformation's coordinate system.mapRect()
is even documented to return the bounding box, for rotating or shearing transforms, which sounds like exactly what we'd want. (A full-HD video rotated to 45° isn't actually1920px × 1080px
, after all — it's somewhat narrower, but significantly taller than that.)And for initial rotation, like in vertical video (most of which is stored at horizontal dimensions with a 90° initial rotation), ideally we'd want libopenshot to consider that video's
width
to be1080
, and its height to be1920
. Which may not be possible with the current rotation logic, as it simply applies the in-built rotation as a default initial value of OpenShot'sRotation
property. That doesn't seem good enough, if we even need to translate the dimensions.The text was updated successfully, but these errors were encountered: