非常基本的Moviepy脚本无法运行

时间:2018-07-01 13:52:03

标签: python ffmpeg moviepy

所以,我有一个非常基本的脚本,可以连接两个视频,并添加背景声音。

def intro():

    voiceoverIntro = AudioFileClip(audio[3]) #get path for intro.mp3


    introVideo = []
    temp = p1vid + p2vid + p3vid

    for x in temp: # add product videos to introVideo if they are longer than intro.mp3
        x = VideoFileClip(x)

        if x.duration >= voiceoverIntro.duration:
            introVideo.append(x)


    if len(introVideo) >= 1:

        #Get the video and turn off its volume
        introBg = introVideo[0].volumex(0).resize((1280,720))
        introBg = introBg.set_audio(voiceoverIntro).set_duration(voiceoverIntro.duration)


        introBg.reader.close()
        introBg.audio.reader.close_proc()

        return introBg

此函数创建第二个剪辑

def productThreeOpener(productName):
    opener3 = VideoFileClip("media/number3.mp4").volumex(0).resize((1280,720))



    text = TextClip(productName,fontsize=60,color='white', font="Dekar")\
        .set_pos(("right", "center"))\
        .set_duration(3)\
        .set_start(2)\
        .crossfadein(1)\
        .crossfadeout(1)\
        .margin(right=200,opacity=0)

    opener3 = CompositeVideoClip([opener3, text])

    return opener3

现在我们将两个输出连接起来

final_clip = concatenate_videoclips([intro,productThreeOpener],method =“ compose”)

final_clip.resize((1280,720))。write_videofile(“ output / intro.mp4”,线程= 8,fps = 24,progress_bar = False)

运行上面的代码将返回此错误;

Traceback (most recent call last):
[MoviePy] >>>> Building video output/intro.mp4
  File "C:/Users/Akbulut/PycharmProjects/youtubeVideoEditor/vidEditor/sandbox.py", line 145, in <module>
[MoviePy] Writing audio in introTEMP_MPY_wvf_snd.mp3
    final_clip.write_videofile("output/intro.mp4", threads=8, fps=24, progress_bar=False)
  File "<decorator-gen-51>", line 2, in write_videofile
  File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-50>", line 2, in write_videofile
  File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-49>", line 2, in write_videofile
  File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "C:\Program Files\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 318, in write_videofile
    progress_bar=progress_bar)
  File "<decorator-gen-73>", line 2, in write_audiofile
  File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 213, in write_audiofile
    progress_bar=progress_bar)
  File "<decorator-gen-70>", line 2, in ffmpeg_audiowrite
  File "C:\Program Files\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 165, in ffmpeg_audiowrite
    ffmpeg_params=ffmpeg_params)
  File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 71, in __init__
    self.proc = sp.Popen(cmd, **popen_params)
  File "C:\Program Files\Python36\lib\subprocess.py", line 594, in __init__
    _cleanup()
  File "C:\Program Files\Python36\lib\subprocess.py", line 205, in _cleanup
    res = inst._internal_poll(_deadstate=sys.maxsize)
  File "C:\Program Files\Python36\lib\subprocess.py", line 1025, in _internal_poll
    if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] İşleyici geçersiz
Exception ignored in: <bound method FFMPEG_AudioWriter.__del__ of <moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter object at 0x0000000A885019B0>>
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 134, in __del__
    self.close()
  File "C:\Program Files\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 122, in close
    if self.proc:
AttributeError: 'FFMPEG_AudioWriter' object has no attribute 'proc'

Process finished with exit code 1

我严格遵循MoviePY安装指南,大约2天前安装了它及其所有依赖项。我在64b Windows计算机上工作。 Python版本3.6.1

我已经被这个错误困扰了整整一天,而且我也不知道该怎么办。非常感谢您提供任何帮助/建议。

谢谢。

0 个答案:

没有答案