2016-02-04 98 views
3

我正在研究一個使用MoviePy庫的圖片和音樂文件並創建視頻文件的python腳本。不幸的是,我面臨着我無法解決的問題。當我嘗試定義的AudioFile我得到這個錯誤:使用MoviePy的TypeError

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

這裏是我的代碼:

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) 

我是相當新的Python的,所以如果有人可以幫助我解決這問題,這將是巨大的:)

以下是完整的錯誤:

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 
+0

哪一行會引發錯誤? – wpercy

+0

clip = clip.set_audio(AudioFileClip(「music.mp3」)) – Fuze

+0

請粘貼整個錯誤信息。總是經過整個錯誤信息。 – Zulko

回答

2

要導入你應該使用IMAGECLIP(圖像),而不是VID eoFileClip()。也許這是問題?

+0

不,不起作用:/ – Fuze