mlt icon indicating copy to clipboard operation
mlt copied to clipboard

Allow arbitrary rotations by being able to specify an anchor point [qtblend]

Open balooii opened this issue 4 months ago • 4 comments

Hi!

I think it would be a nice addition for the qtblend filter to be able to set the rotation anchor point so you can rotate around any point you want.

I (mis)used a rect type parameter for this as I didn't find a point-equivalent parameter type and just used x and y component out of it.

If you're interested in this change I'd be happy to change it to something more appropriate if you can guide me :slightly_smiling_face:

Here are some examples how it could be used:

Rotate around bottom-right corner (1,1)

melt -profile hdv_720_25p color:red length=100 -filter qtblend rect="100 100 200 200 1" rotation=90 rotate_anchor="1 1 0 0 0" -consumer avformat:test_bottomright.mp4

Rotate around some point outside the rectangle (-0.5, 0.5)

melt -profile hdv_720_25p color:red length=100 -filter qtblend rect="100 100 200 200 1" rotation=45 rotate_anchor="-0.5 0.5 0 0 0" -consumer avformat:test_outside.mp4

Rotate around center (0.5, 0.5), equivalent to rotate_center set to 1

melt -profile hdv_720_25p color:red length=100 -filter qtblend rect="100 100 200 200 1" rotation=45 rotate_anchor="0.5 0.5 0 0 0" -consumer avformat:test_center.mp4

Rotate around top-left corner (0, 0), equivalent to rotate_center set to 0

melt -profile hdv_720_25p color:red length=100 -filter qtblend rect="100 100 200 200 1" rotation=45 rotate_anchor="0.5 0.5 0 0 0" -consumer avformat:test_topleft.mp4

In Inkscape this could be done like so:

inkscape_rotation_anchor.webm

balooii avatar Aug 06 '25 11:08 balooii

I (mis)used a rect type parameter

That is fine. A lot of rect properties in MLT do not utilize the opacity field, and that is OK. However, an alternative is anchor_x and anchor_y. I do not have a preference. I want you to explore which is more convenient for Kdenlive and reply with your decision. Thank you

ddennedy avatar Aug 06 '25 17:08 ddennedy

Thank you, I have reached out to JBM for another opinion.

Aesthetically I think I would prefer the two double params than using a rect for a point but don't really have a opinion.

I haven't looked at the Kdenlive keyframe/param model too deeply and don't know the one from Shotcut at all so maybe there is a preference based on how it will be used there at some point.

balooii avatar Aug 06 '25 19:08 balooii

Previously I wrote that Shotcut does not use qtblend. Well, it does use the transition now for track blending; so, I deleted it. But it does not use it as a transform filter. I recently had to do some work on the Shotcut Corner Pin UI, which is based on 4 points, and Shotcut does not have a point parameter type. The underlying frei0r plugin uses 2 distinct number parameters to represent the point. I used rect params in its UI, which has a visual control. It was quite a bit of ugly extra work to coordinate the rect-as-point with the discrete numbers--unrelated to rect having more fields than necessary. So, my vote is to use rect in case I adopt this into Shotcut or port it to another filter. However, priority goes to Kdenlive devs.

ddennedy avatar Nov 21 '25 18:11 ddennedy

Thanks Dan for the input. I am also in favor of using a rect to handle position parameters. Reviewing this MR is on my todo list, hopefully I can move on with this in the coming weeks.

j-b-m avatar Nov 24 '25 07:11 j-b-m