BrokenSource / DepthFlow

🌊 Images to → 2.5D Parallax Effect Video. A Free and Open Source ImmersityAI alternative
https://brokensrc.dev
MIT License
456 stars 29 forks source link

How to keep animation run just once during the time period? #60

Open C00reNUT opened 3 days ago

C00reNUT commented 3 days ago

🔘 Request type

General feedback

🔘 Description

Hello,

I am playing with the cli of the tool using command

WINDOW_BACKEND=headless depthflow dolly input -i 1.jpg main --quality 80 --ssaa 2 -w 1280 -h 720 -o ./output_depth.mp4 --time 10 --loop 1

I would like to achieve that the dolly animation repeats only once during the 10 second time period - in another words the start and last frame shall be the same during the animation and the effect shall run/repeat just once during the time period. This shall be independent of total time duration set for the video - that means that this effect shall be the same if I set time to 5 seconds, just the dolly zoom will run 'quicker' but the starting and ending frame will be the same and the effect will run just once.

Is it possible to achieve this using just cli? I have tried the loop parameter but that loops the present video multiple times which is not what I want to achieve...

Thank you in advance :)

Edit: Is it possible to achieve this in general for all effects/animations?

Tremeschin commented 3 days ago

hi again!

I would like to achieve that the dolly animation repeats only once during the 10 second time period - in another words the start and last frame shall be the same during the animation and the effect shall run/repeat just once during the time period

Your command is right, and it does loop once every 10 seconds! it's just that the animation must start mid-way through for the --reverse parameter to have an effect (see this comment for more context). Try starting the video at 25% through and pay attention it "zooms out then in", looping back to where you started, use --time 5 for the 5 second one!

The last frame isn't quite the first one because that would duplicate it, there's a single frametime of difference between the two, which is in fact the same delta time for all frames when exporting

The --loop N copies the video N - 1 times to the right, if one wants to save rendering time or extend the output video's length; for depthflow that's precisely one animation loop, final length period * loop


This shall be independent of total time duration set for the video - that means that this effect shall be the same if I set time to 5 seconds (...) Is it possible to achieve this in general for all effects/animations?

Yes, the total export time defines the period duration of the animations for depthflow. In fact, everything on shaderflow engine bases off the time:

C00reNUT commented 3 days ago

Thank you for pointing me to https://github.com/BrokenSource/DepthFlow/issues/37#issuecomment-2342306836 it explains the issue.

The thing is that this issue with asymmetry is not only with dolly using reverse flag but also with regular one (see below). The animation loop completes one cycle at 7.5 seconds and then starts to repeat itself until it reaches 10sec.

But probably I am just repeating myself and just didn't get some of your explanations :) I just wasn't sure whether it's a feature or a bug... In the end if it's always 75 percent of the duration of the output it is very easy to write simple ffmpeg script that will always cut the video output, it's just not very elegant solution :P

dolly reverse:

WINDOW_BACKEND=headless depthflow dolly --reverse input -i m.png main --quality 80 --ssaa 2 -w 1280 -h 720 -o ./m_dolly_reverse.mp4 --time 10

https://github.com/user-attachments/assets/36ee9225-bbbf-4ab9-8627-7f6b5344308f

dolly without reverse:

WINDOW_BACKEND=headless depthflow dolly input -i m.png main --quality 80 --ssaa 2 -w 1280 -h 720 -o ./m_dolly_reverse.mp4 --time 10

https://github.com/user-attachments/assets/4dc3ea76-72a5-4e7e-821c-711f0f38b9ab

Tremeschin commented 2 days ago

Fixed with https://github.com/BrokenSource/DepthFlow/commit/09e4bfeb7a22b1cc88deaa7cabb16053d413a7ab, is this what one would expect? 🙂

depthflow dolly main -o /tmp/loop-forward.mp4 -t 5 https://github.com/user-attachments/assets/3030d494-9d13-4e84-b154-3bcb5f5c0bc0
depthflow dolly --reverse main -o /tmp/loop-reverse.mp4 -t 5 https://github.com/user-attachments/assets/290efba5-6690-4c9a-93f8-664fa3ef90e2
depthflow dolly --no-loop main -o /tmp/linear-forward.mp4 -t 2.5 https://github.com/user-attachments/assets/b0a2511f-9d7c-4d61-ac97-f43c604df606
depthflow dolly --reverse --no-loop main -o /tmp/linear-reverse.mp4 -t 2.5 https://github.com/user-attachments/assets/17f200a3-c570-4cc0-8389-95b8706f4329

You can run it directly from source https://brokensrc.dev/get/source/ right now, just beware I'm working in some core classes overhaul/rewrite and it might break with dumb stuff I didn't notice