Python Forum
TypeError: 'float' object is not callable #1 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: TypeError: 'float' object is not callable #1 (/thread-39250.html)



TypeError: 'float' object is not callable #1 - isdito2001 - Jan-20-2023

Good evening, can you help me and tell me what I am doing wrong because it tells me that it is not callable. reggards

# Import Pmw from this directory tree.
#!/usr/local/bin/python
# -*- coding: UTF-8 -*-
from moviepy.editor import CompositeVideoClip, VideoFileClip, TextClip, concatenate_videoclips,vfx
import time
import math

clip2 = VideoFileClip("F:/ave-maria-mosca.mp4")

tiem=0.0
print ("eee")
tiempo_ralentizado=4   #4 segundos
lugar_ralentizado=5   #En el segundo 5
Framerate=50
arco_ralen=tiempo_ralentizado*Framerate


def tiempo(tiem,tiempo_ralentizado,lugar_ralentizado,Framerate,arco_ralen):
    gek=tiem
    punto_entrada=lugar_ralentizado -( tiempo_ralentizado /2 )
    print (gek, abs(math.sin(gek/arco_ralen)), punto_entrada)
    donde=[2]
    calcular=abs(math.sin(gek/4)*2)
    return gek+1- calcular

clip2 = clip2.fl_time( tiempo(tiem,tiempo_ralentizado,lugar_ralentizado,Framerate,arco_ralen) ).set_duration(40)
give me this error

Error:
File "F:\post-produccion.py", line 35, in <module> clip2 = clip2.fl_time( tiempo(tiem,tiempo_ralentizado,lugar_ralentizado,Framerate,arco_ralen) ).set_duration(40) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\moviepy\Clip.py", line 190, in fl_time return self.fl(lambda gf, t: gf(t_func(t)), apply_to, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\moviepy\Clip.py", line 138, in fl newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-57>", line 2, in set_make_frame File "C:\Python311\Lib\site-packages\moviepy\decorators.py", line 14, in outplace f(newclip, *a, **k) File "C:\Python311\Lib\site-packages\moviepy\video\VideoClip.py", line 666, in set_make_frame self.size = self.get_frame(0).shape[:2][::-1] ^^^^^^^^^^^^^^^^^ File "<decorator-gen-10>", line 2, in get_frame File "C:\Python311\Lib\site-packages\moviepy\decorators.py", line 89, in wrapper return f(*new_a, **new_kw) ^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\moviepy\Clip.py", line 95, in get_frame return self.make_frame(t) ^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\moviepy\Clip.py", line 138, in <lambda> newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\moviepy\Clip.py", line 190, in <lambda> return self.fl(lambda gf, t: gf(t_func(t)), apply_to,



RE: TypeError: 'float' object is not callable #1 - Yoriz - Jan-21-2023

https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html#moviepy.video.io.VideoFileClip.VideoFileClip.fl_time Wrote:fl_time(self, t_func, apply_to=None, keep_duration=False)
Returns a Clip instance playing the content of the current clip but with a modified timeline, time t being replaced by another time t_func(t).

Parameters
t_func:
A function t-> new_t
The method fl_time of VideoFileClip states that the parameter it receives is a function.
your line
clip2 = clip2.fl_time( tiempo(tiem,tiempo_ralentizado,lugar_ralentizado,Framerate,arco_ralen) ).set_duration(40)
is passing the result of a function, not an actual function itself.