Ken Burns Zoom Refinements (Ping-Pong Loop) #230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description: Ken Burns Zoom Refinements (Ping-Pong Loop)
Summary
This PR introduces a configurable "Ping-Pong" (Zoom In/Out) effect to the image-to-video conversion service. It addresses the limitation of the linear zoom, which can become visually overwhelming on long videos. This feature is fully backward compatible.
Changes
API Update: Added two optional parameters to
POST /v1/image/convert/video:zoom_effect(string, enum:["linear", "ping-pong", "loop"]): Defaults to"linear".zoom_loop_duration(number): Optional duration (in seconds) for a full loop cycle. Defaults to video length if not provided.Service Logic:
zoompanfilter whenzoom_effect="ping-pong".z = 1 + ({zoom_speed}*{length}) * (1 - abs(2 * mod(on, loop_frames)/loop_frames - 1))Backward Compatibility:
zoom_effectis omitted, it defaults to"linear", triggering the original code path.zoom_loop_durationis omitted, it defaults to the full video length (creating one single cycle for the duration of the video).Usage Examples
1. Default (Linear Zoom) - Unchanged
{ "image_url": "https://example.com/image.jpg", "length": 5 }2. Ping-Pong Effect (Full Video)
Zooms in and then out once over the entire duration.
{ "image_url": "https://example.com/image.jpg", "length": 10, "zoom_effect": "ping-pong" }3. Ping-Pong Effect (Frequency Based)
Oscillates (In -> Out -> In) every 30 seconds.
{ "image_url": "https://example.com/image.jpg", "length": 60, "zoom_effect": "ping-pong", "zoom_loop_duration": 30 }