Coder Social home page Coder Social logo

Comments (8)

Zulko avatar Zulko commented on May 20, 2024

I am not sure that I understand exactly what you want, but you can change the timeline of a clip very freely with clip.fl_time(some_time_warping_function). Here is an example in which the timeline is replaced by t+sin(t), so that the clip will gradually be sped up and slowed down, with a period of 2Pi seconds (this applies to the audio and the video):

clip = VideoFileClip("my_video.mp4")
clip2 = clip.fl_time( lambda t: t+ sin(t) )
clip2.to_videofile("my_time_warped_video.mp4")

To slow down a clip progressively a clip of N seconds you would write something like

clip.fl_time(lambda t: N*t/(N+t)).set_duration(2*N)

Now if you have a profile of the speed over time, you could integrate this profile to get the profile of a timeline, which you can tranform into a function timeline(t) and then clip.fl_time(timeline) would do the trick.

I don't know if there is a proper Bezier curve library in Python. That would certainly be a job for Scipy.

from moviepy.

cnelsonsic avatar cnelsonsic commented on May 20, 2024

That sounds like what I'm after. I'll give it a shot.
Thanks!

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Cool. Note that 'going back in time' (i.e. negative speed) is possible for the video but not fully tested with the audio (you might run into a bug).

from moviepy.

SreeniASU avatar SreeniASU commented on May 20, 2024

Hi Zulko,
I tried this and it seems that the speed of the video clip changes, whereas the accompanying audio doesn't speed up. The file format is mp4. Can you please help?

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Try this, with apply_to=['audio'] in fl_time:

clip = VideoFileClip("my_video.mp4")
clip2 = clip.fl_time( lambda t: t+ sin(t), apply_to=['audio'] )
# maybe indicate a new duration for the clip:
clip2 = clip2.set_duration(some_new_duration)
clip2.write_videofile("my_time_warped_video.mp4")

from moviepy.

SreeniASU avatar SreeniASU commented on May 20, 2024

Thanks Zulko for your quick response. It worked like a charm. But, I have one more concern. On changing the playback rate of the video the voice of the person in it also changes. That is, if I double or halve the speed of video, the dialogues are clear, but the voice becomes annoyingly unpleasant. This doesn't happen if I play the original video in a video player with 2x or 0.5x speed. Is there any way to avoid that?

from moviepy.

isdito avatar isdito commented on May 20, 2024

hello,
I'm looking for a way to slow down a point in the video but then x time later it returns to normal speed.

Imagine recording it at 50 fps or 100 fps per second while its playback is constant at 1/25, when the car is close then use those frames. Typical of after effects programs is a retime curve.

Slow down a point of the video and then continue normal

any help please

from moviepy.

keikoro avatar keikoro commented on May 20, 2024

Please note that you are commenting on old, closed issues meaning only very few people will see your comments.

from moviepy.

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.