question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fill and Fit video transformation

See original GitHub issue

It looks to be not really obvious how to transform video size to Fill or Fit the new requested frame size. Will appreciate any guidance on how it’s possible to do that in a proper way.

For example, I have a video with the following params:

sourceWidth = 2160
sourceHeight = 3840
rotation = -0.0

and I’m willing to transform it to the following size and fill the frame:

width = 1080
height = 592

This code will work for me:

Transform(
  PointF(1 + sourceWidth.toFloat() % width, (sourceHeight.toFloat() / height) / (sourceWidth / width)),
  PointF(0.5f, 0.5f),
  rotation,
)

However, the same logic won’t work for:

sourceWidth = 720
sourceHeight = 1280
rotation = -90.0

Even assuming we are rotating the video from 90 to 0 degrees I’ve tried to replace x with y, but still no luck. The frame is being stretched.

There are many different scenarios of transformation I need to handle such:

  • Square video (FILL/FIT)
  • Portrait video 16/9 (FILL/FIT)
  • Landscape video 9/16 (FILL/FIT)
  • Original video size (FILL/FIT) where initial size is determined by the first uploaded video. All these options could be applied for video sets with different video sizes, so I need some generic logic here to calculate the final transformation.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
novachevskyicommented, Nov 7, 2022

Yes, please close it.

On Mon, Nov 7, 2022, 4:52 PM Izzat Bahadirov @.***> wrote:

@novachevskyi https://github.com/novachevskyi Are things working well for you? Can we close this issue?

— Reply to this email directly, view it on GitHub https://github.com/linkedin/LiTr/issues/218#issuecomment-1305729536, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP2B764LH2KLDV5ZEIZ2HDWHEJUHANCNFSM6AAAAAAQVVXLDY . You are receiving this because you were mentioned.Message ID: @.***>

1reaction
novachevskyicommented, Sep 27, 2022

@izzytwosheds thanks for the explanation! I guess it works for me when I’m setting rotation to 0 in the target track object. I’ll keep testing and will let you know if something won’t work as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Make your Clips Fit to Frame, Fit to Width & Height in ...
In this video tutorial, I show you how to make your clips or images fit the frame of the viewing window automatically for...
Read more >
Video Resizer Online - Clideo
Change video dimensions for free with ready presets for Instagram, Facebook, YouTube, Twitter, Snapchat, LinkedIn, and Pinterest.
Read more >
Dynamically Resizing and Cropping Videos - Cloudinary
Resize and crop mode examples; fill; fill_pad; crop; scale; fit ... Resizing the video to 200 x 200 pixels, using crop, scale, fill...
Read more >
How to Change the Aspect Ratio of your Videos for Free?
How to Change Aspect Ratio in Windows 10. Step 1: Open Animotica; Step 2: Change Your Aspect Ratio; Step 3: Apply Fit/Fill; Step...
Read more >
Resize, move, and rotate clips in Final Cut Pro - Apple Support
In Final Cut Pro, use the Transform effect to resize, rotate, and move video or still-image clips.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found