Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError using MoviePy

Tags:

python

I'm working on a python script that takes a picture and a music file and create a video file using MoviePy library. Unfortunatly, I'm facing a problem I'm not able to resolve. When I try to define the AudioFile I get this error :

TypeError: 'float' object cannot be interpreted as an integer

Here's my code:

from moviepy.editor import *

clip = VideoFileClip("my_picture.jpg")
clip = clip.set_audio(AudioFileClip("music.mp3"))
clip = clip.set_duration(8)
clip.write_videofile("movie.mp4",fps=15)

I'm fairly new to Python so if someone could help me sort this problem it would be great :)

Here's the full error:

  File "movietest.py", line 5, in <module>
    clip = clip.set_audio(AudioFileClip("music.mp3"))
  File "C:\Users\Julien_Dev\AppData\Local\Programs\Python\Python35-32\lib\site-packages\moviepy-0.2.2.11-py3.5.egg\moviepy\audio\io\AudioFileClip.py", line 63, in __init__
    buffersize=buffersize)
  File "C:\Users\Julien_Dev\AppData\Local\Programs\Python\Python35-32\lib\site-packages\moviepy-0.2.2.11-py3.5.egg\moviepy\audio\io\readers.py", line 70, in __init__
    self.buffer_around(1)
  File "C:\Users\Julien_Dev\AppData\Local\Programs\Python\Python35-32\lib\site-packages\moviepy-0.2.2.11-py3.5.egg\moviepy\audio\io\readers.py", line 234, in buffer_around
    self.buffer =  self.read_chunk(self.buffersize)
  File "C:\Users\Julien_Dev\AppData\Local\Programs\Python\Python35-32\lib\site-packages\moviepy-0.2.2.11-py3.5.egg\moviepy\audio\io\readers.py", line 123, in read_chunk
    self.nchannels))
TypeError: 'float' object cannot be interpreted as an integer
like image 280
Fuze Avatar asked Aug 09 '26 00:08

Fuze


1 Answers

To import an image you should use ImageClip(), not VideoFileClip(). Maybe that's the issue ?

like image 122
Zulko Avatar answered Aug 11 '26 13:08

Zulko