尝试用moviepy编写CompositeVideoClip时,如何解决“ AttributeError:'NoneType'对象没有属性'stdout'”?

时间:2019-11-27 21:27:57

标签: python moviepy

我正在使用以下内容:

from moviepy.editor import *

ukulele = VideoFileClip("./clips/513732763.mp4")

txt = TextClip("some text", color='white').set_duration(3)

final = CompositeVideoClip([ukulele,txt])
final.write_videofile("video.mp4",codec="libx264")

我想做的是在视频文件剪辑上添加文本。与正常写作 VideoFileClip在工作,但是,在使用CompositeVideoClip时却不能。 但是,在使用Python 3.6.9运行时,出现以下错误:

Moviepy - Building video video.mp4.
MoviePy - Writing audio in videoTEMP_MPY_wvf_snd.mp3
chunk:  12% 52/447 [00:00<00:00, 518.22it/s, now=None]Traceback (most recent call last):
  File "main.py", line 8, in <module>
    final.write_videofile("video.mp4",codec="libx264")
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 317, in write_videofile
    logger=logger)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-73>", line 2, in write_audiofile
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 209, in write_audiofile
    logger=logger)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-70>", line 2, in ffmpeg_audiowrite
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
    logger=logger):
  File "/usr/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 85, in iter_chunks
    fps=fps, buffersize=chunksize)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-72>", line 2, in to_soundarray
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 126, in to_soundarray
    snd_array = self.get_frame(tt)
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "</usr/lib/python3.6/site-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/usr/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/io/AudioFileClip.py", line 78, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 184, in get_frame
    self.buffer_around(fr_max)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 238, in buffer_around
    array = self.read_chunk(chunksize)
  File "/usr/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 112, in read_chunk
    s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'

除编写CompositeVideoClip之外,所有其他信息均正确无误,并且可以正常工作。我怎么会 去解决这个问题?

1 个答案:

答案 0 :(得分:0)

这是moveipy 1.0.1的一个已知问题,在这里https://github.com/Zulko/moviepy/issues/938有一个开放的github问题

就目前而言,最好的做法似乎是恢复到1.0.0版,该版本已帮助该线程上的一些人以及我本人。 您可以使用pip install moviepy==1.0.0(注意,双“ =“)