Giter Club home page Giter Club logo

Comments (12)

DarthSim avatar DarthSim commented on May 29, 2024

Hey @routehero!

vtt always does "resize--to-fit" scaling. Currently, the only way to get tiles of the exact size provided is using the extend_tile argument of vtt: vtt:1:5:5:120:160:1. Though I guess this is not what you want.

from imgproxy.

routehero avatar routehero commented on May 29, 2024

extend is cool, but first I'd like to ensure that every thumbnail in the tile is cropped/scaled.

Goal is to get 9:16 thumbs in the tile.

from imgproxy.

DarthSim avatar DarthSim commented on May 29, 2024

I can add an argument that would enable "resize-to-fill" scaling of the tiles, but it will always use the center of a frame (as with ce gravity). Would it work for you?

from imgproxy.

routehero avatar routehero commented on May 29, 2024

On our site, we plan to have a feature where the user can select a 9:16 portion of a 16:9 video.

Using ffmpeg, I would do something like:

only iframes:
ffmpeg -y -skip_frame nokey -i ../bbb_sunflower_1080p_30fps_normal.mp4 -vf "fps=1/5,crop=x=0:y=0:w=ih*9/16,scale=480:640,tile=5x5" test%05d.jpg

all frames:
ffmpeg -y -i ../bbb_sunflower_1080p_30fps_normal.mp4 -vf "fps=1/5,crop=x=0:y=0:w=ih*9/16,scale=480:640,tile=5x5" test2%05d.jpg

Being able to specify the x= parameter in this case is key to the feature, so center-based gravity would not be appropriate.

from imgproxy.

DarthSim avatar DarthSim commented on May 29, 2024

Well, it's possible. But I'd rather allow specifying a focus point (like in the fp gravity) instead of offsets. The focus point is generally easier to use and it can have proper defaults (0.5x0.5 for center). From the frontend's point of view, it's a little bit more complex but not rocket science. Basically, it can be calculated as (x_offset + selected_area_width/2) / video_width. What do you think about this?

from imgproxy.

routehero avatar routehero commented on May 29, 2024

Sounds good to me.

from imgproxy.

DarthSim avatar DarthSim commented on May 29, 2024

I made a test build test-vtk-fill that adds 3 additional arguments to vtt. Now its arguments look like this:

vtt:%step:%columns:%rows:%tile_width:%tile_height:%extend_tile:%trim:%fill:%focus_x:%focus_y

fill: when set to 1, t or true, imgproxy will resize frames to fill a tile and will crop projecting parts (as with resizing_type:fill).
focus_x and focus_y: floating point numbers between 0 and 1 that define the coordinates of the center of the tile. Treat 0 and 1 as right/left for focus_x and top/bottom for focus_y. Applicable only when fill is used.

Please check if this does the job for you.

from imgproxy.

routehero avatar routehero commented on May 29, 2024

Initial testing looks good to me!

from imgproxy.

DarthSim avatar DarthSim commented on May 29, 2024

Nice! Please drop a line here when you make sure it works for you so I can merge this to the upstream.

from imgproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.