Moviepy: AttributeError: 'NoneType' object has no attribute 'stdout'

Created on 5 Apr 2019  Â·  40Comments  Â·  Source: Zulko/moviepy

Notice

If you have arrived here from google, you will probably find that updating your moviepy version to v1.0.3 or higher will fix the issue (pip install moviepy --upgrade). See #1185.


Expected Behavior

Expected to get an edited version of the inputted video.

Actual Behavior

Produces this error:

Moviepy - Building video test.webm.
MoviePy - Writing audio in testTEMP_MPY_wvf_snd.ogg
chunk:   0%|          | 0/552 [00:00<?, ?it/s, now=None]Traceback (most recent call last):
  File "/home/tech/Developement/CrabRaveGenerator/Test.py", line 8, in <module>
    ]).write_videofile("test.webm", fps = 30)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/video/VideoClip.py", line 317, in write_videofile
    logger=logger)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-73>", line 2, in write_audiofile
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/AudioClip.py", line 209, in write_audiofile
    logger=logger)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-70>", line 2, in ffmpeg_audiowrite
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/io/ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
    logger=logger):
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/AudioClip.py", line 85, in iter_chunks
    fps=fps, buffersize=chunksize)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-72>", line 2, in to_soundarray
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/AudioClip.py", line 126, in to_soundarray
    snd_array = self.get_frame(tt)
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/Clip.py", line 138, in <lambda>
    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/Clip.py", line 190, in <lambda>
    return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
  File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/io/AudioFileClip.py", line 78, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/io/readers.py", line 180, in get_frame
    self.buffer_around(fr_min)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/io/readers.py", line 238, in buffer_around
    array = self.read_chunk(chunksize)
  File "/usr/local/lib/python3.5/dist-packages/moviepy-1.0.0-py3.5.egg/moviepy/audio/io/readers.py", line 112, in read_chunk
    s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'

Steps to Reproduce the Problem

Run the following code:

from moviepy.editor import CompositeVideoClip, VideoFileClip, TextClip

CompositeVideoClip([

    VideoFileClip("template.webm").subclip(5, 30), 
    TextClip("Test Text", fontsize = 70, color = 'white').set_position('center').set_duration(10)

]).write_videofile("test.webm", fps = 30)

Specifications

  • Python Version: 3.5.3
  • Moviepy Version: 1.0.0
  • Platform Name: Debian
  • Platform Version: 9.8
video

Most helpful comment

I've got the same problem (macOS Mojave, python 3.6.x) with moviepy 1.0.1 but I've managed to work around it downgrading it to 1.0.0.

Hope it helps.

All 40 comments

I am facing the same issue

@kamalchaturvedi15 same versions same script ?

@Zulko Yes, same version (1.0.0)

I am trying to subclip a video, and then writing into a file. It works like for 70% of the clips, but not for the rest 30%, even though all parameters I am passing are correct. Below is my code snippet
`new_clip = self.videoEditor.subclip(startTime, endTime)

new_clip_name = 'clipped.mp4'

new_clip.write_videofile(new_clip_name, codec="libx264", temp_audiofile='temp-audio.m4a', remove_temp=True, audio_codec='aac')

new_clip.close()`

This error occurs while generating the audio file I believe, as it breaks at this point :
`MoviePy - Writing audio in %s

chunk: 0%| | 0/1015 [00:00

'NoneType' object has no attribute 'stdout'`

I'm facing the same issue when trying to concatenate two video clips with the kwarg method="compose".

it's a simple code:

from moviepy.editor import *
clip1 = VideoFileClip("video1.avi")
clip2 = VideoFileClip("video2.avi")
final_clip = concatenate_videoclips( [clip1,clip2], method='compose')
final_clip.write_videofile("video3.mp4", fps=30)

gives the result as follow:

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

Python version: 3.5.2
Moviepy: Installed direct from git
Plataform: Ubuntu 16.04.6 LTS in Windows WSL

Hope it helps!

Update:

Same happens when I try to use other kwargs, like in:

txt_clip = ( TextClip("Test",fontsize=70,color='white')
             .set_position('center')
             .set_duration(10) )

Not sure anymore if it is related, or my environment it's just messed up, but I guess everything is ok...

Ok. I encountered the same error, and I was trying to concatenate videos, just like @kaiqueocanha. My debugging led me to a place that whenever I tried to incorporate the initial 30 seconds of the two videos I tested on, I got the same error. Hoping that helps in debugging.

@mraduldubey I believe you meant to tag @kaiqueocanha. I was trying to overlay text, not concatenate multiple videos into one.

I've got the same problem (macOS Mojave, python 3.6.x) with moviepy 1.0.1 but I've managed to work around it downgrading it to 1.0.0.

Hope it helps.

@dcaravana Thanks for letting us know. There seems to be a lot of errors and PRs about this proc that is causing all the problems. Part of the problem seems to be fixing errors on windows which then breaks it on Linux, and vice versa. The only change to it in v1.0.1 vs v1.0.0 is https://github.com/Zulko/moviepy/commit/350571acfe620bf1479fba555d55efb28d51e568. Would you mind manually reverting that change to check that the old version still works? Perhaps PR #1016 helps your bug?

I changed to v1.0.0, and it works well.

@tburrows13 sadly none of them worked.

If it can be of any help here follows the last part of the stack trace:

...
  File "</Users/diego/work/mvp/explainapi/.venv/lib/python3.6/site-packages/decorator.py:decorator-gen-10>", line 2, in get_frame
  File "/Users/diego/work/mvp/explainapi/.venv/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/Users/diego/work/mvp/explainapi/.venv/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/Users/diego/work/mvp/explainapi/.venv/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 "/Users/diego/work/mvp/explainapi/.venv/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 191, in get_frame
    self.buffer_around(fr_max)
  File "/Users/diego/work/mvp/explainapi/.venv/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 245, in buffer_around
    array = self.read_chunk(chunksize)
  File "/Users/diego/work/mvp/explainapi/.venv/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'

@tburrows13 I spent some time on the issue, but basically it's more complicated than expected to understand for the time I've got, with all those interactions between different parts of moviepy.

Anyway the main issue seems to be how the data is read from ffmpeg through the process created by Popen and assigned to self.proc in audio/io/readers.py: after 100 read_chunk calls, self.proc becomes None.

I've also tried with two different video files.

It could also be that the original code was flawed and the new version of moviepy just let the problem emerge.

Hope it helps!

Changed to v1.0.0 and it gives no error. Thanks guys

Same problem on OSX high sierra, python 3.6. Downgrade to 1.0.0 fixes issue.

I've got the same problem (macOS Mojave, python 3.6.x) with moviepy 1.0.1 but I've managed to work around it downgrading it to 1.0.0.

Hope it helps.

This one surprisingly working solution to the issue. Thanks @dcaravana ✌. It's really under my estimation to think of downgrading can be a solution!

Would those of you for whom downgrading to moviepy 1.0.0 fixed the issue mind helping us out a little bit?

The only commit that I can see would cause this to happen is https://github.com/Zulko/moviepy/commit/350571acfe620bf1479fba555d55efb28d51e568

Would you mind upgrading to v1.0.1, finding the files referenced in the above commit and undo the changes it references and report back. I’m pretty sure that should fix your problem but @dcaravana said that it didn’t help him...

@tburrows13 I've encountered the same issue, downgrading "solved" it so I tried reverting the indicated code from 350571acfe620bf1479fba555d55efb28d51e568: this didn't work out.

Looked a bit further at the changes between v1.0.0 and v1.0.1 I think I narrowed it down to these lines coming from #931, commit: https://github.com/Overdrivr/moviepy/commit/f4a562534d54d1bd190836f7b9e92350a8426cb9#diff-2b5c494ba3a48ff925aca6438d9847a7R92-R94

I don't (and didn't try to) understand all internals, but it would make sense as an AudioClip.audio_normalize() triggered the issue for me and AudioClip is involved in all posted stack traces in this ticket.

Upgrading to v1.0.1 and just commenting these lines fixed the issue (for me).

Hope this helps! Keep up the great work!

pip install moviepy==1.0.0

bug fixed!

@sebasi Hi, can you specify which lines exactly that you commented out? I'm having trouble finding the ones you mentioned.

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

@sebasi Wow thanks! This did seem to fix the issue, however this only worked once I downgraded to from Python 8 to Python 7, and even then I'm not positive whether or not it was changing the script or downgrading python.

This still does not fix the main issue of write_videofiles() producing videos which are frozen on the first frame.

Not sure if I understood you correctly, but I meant that you have to adjust the path to your python version.
Unfortunately I cannot tell you anything about the other issue you are having.

@sebasi Would you mind telling me what exact version of python you are using?

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

This fixed it for me. Tnaks

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

@Zulko please remove the destructor in the last line, as this works perfectly!

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

Thank you @sebasi it worked for me perfectly.

This works for me on macOS 10.14 with moviepy 1.0.1

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

Hey all! This is obviously a problem that needs sorting. It has built up over time with people making quick fixes to small parts of the code without taking into consideration that the same methods should be applied consistently to all of moviepy, and also that different operating systems handle resources differently. Around eastertime I intend to have a proper look at it across different OSs and hopefully come up with a solution that works for everyone.

@Ethan0429 So here are the steps:

  1. Make sure you upgrade to version 1.0.1
  2. go to the moviepy directory (you need to adjust for your python version):
    cd /usr/local/lib/python3.7/dist-packages/moviepy/
  3. edit the AudioFileClip class at line 93, e.g. with vim: vim audio/io/AudioFileClip.py +93
  4. comment these lines (add an # in front of them):
    # def __del__(self):
    # self.close()
  5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

It looks like i have the same problem and the fix you listed did not fix it. Attaching my stack trace.

  File "mytest.py", line 49, in <module>
    final_video.write_videofile('mytest.mp4', fps=60)
  File "<decorator-gen-51>", line 2, in write_videofile
  File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy/video/VideoClip.py", line 317, in write_videofile
    logger=logger)
  File "<decorator-gen-73>", line 2, in write_audiofile
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 209, in write_audiofile
    logger=logger)
  File "<decorator-gen-70>", line 2, in ffmpeg_audiowrite
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
    logger=logger):
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 85, in iter_chunks
    fps=fps, buffersize=chunksize)
  File "<decorator-gen-72>", line 2, in to_soundarray
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 126, in to_soundarray
    snd_array = self.get_frame(tt)
  File "<decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "<decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "<decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "<decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 296, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 297, in <listcomp>
    if (part is not False)]
  File "<decorator-gen-10>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy/audio/io/AudioFileClip.py", line 78, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
AttributeError: 'NoneType' object has no attribute 'get_frame'

I confirm @sebasi fix works for me on moviepy version 1.0.1.

When clips of different lengths are composited, the composite clip has the duration of the longest clip, assuming all clips have a duration (at the end of the video, only the last clip is playing).

@Zulko Yes, you are correct. Sorry, I was wrong. I deleted my post. Different length clips can be composited without issue.

I think i am getting the same issue with CompositeAudioClip that is made out of a concatenate_audioclips object and video audio track:
relevant parts of the code:

music_background = concatenate_audioclips(bg_music_playlist)

composited_audio = CompositeAudioClip([final_video.audio, music_background]).set_duration(speech_audio_duration)

last bits of error message:

venv/lib/python3.7/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'

Reverting to version 1.0.0 have fixed things for me..

same here, annoying error.
MacOS Catalina 10.15.3 with Python 3.8.1
fixed downgrading to 1.0.0

Same issue. Python 3.7. None of the solutions above worked.

After trying multiple times, I can confirm that the solution also works for 1.0.2.

@Ethan0429 So here are the steps:

1. Make sure you upgrade to version 1.0.1

2. go to the moviepy directory (you need to adjust for your python version):
   `cd /usr/local/lib/python3.7/dist-packages/moviepy/`

3. edit the AudioFileClip class at line 93, e.g. with vim: `vim audio/io/AudioFileClip.py +93`

4. comment these lines (add an `#` in front of them):
   `#    def __del__(self):`
   `#        self.close()`

5. save and exit the editor

And you should be done.

Could you please confirm if this works for you?
Cheers

PS: I've put it quite detailed to potentially assist other people. :)

However I am getting "OSError: [WinError 6] The handle is invalid" errors. I added "clip.reader.close()", but this did not solve the problem. After a couple of runs, the error would occur again, and I had to restart my IDE. I suppose this is an unrelated issue.

I have the same issue when using write_videofile.
I am using linux mint 19.2, python 3.7 and moviepy 1.0.2.
Downgrading to 1.0.0 didnt work.
Using the 1.0.1 version and commenting the the lines of the function def __del__(self): in the file /audio/io/readers.py also didnt work
In every case, always the same issue:
AttributeError: 'NoneType' object has no attribute 'stdout'

I have the same issue when using write_videofile.
I am using linux mint 19.2, python 3.7 and moviepy 1.0.2.
Downgrading to 1.0.0 didnt work.
Using the 1.0.1 version and commenting the the lines of the function def del(self): in the file /audio/io/readers.py also didnt work
In every case, always the same issue:
AttributeError: 'NoneType' object has no attribute 'stdout'

The python what you changed maybe not the python when you run. Or the plugin you changed is not the plugin when you run.

Fixed in #1185 and version 1.0.3. Thank you everyone for your patience! Use `pip install moviepy --upgrade`` to update to the latest version.

unfortunately I'm still facing the issue with the new version :(. I'm attaching the error trace:

Moviepy - Building video test.mp4.
MoviePy - Writing audio in testTEMP_MPY_wvf_snd.mp3
chunk:   0%|                                                                                                                                                   | 0/59 [00:00<?, ?it/s, now=None]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 49, in create_new_video
  File "<decorator-gen-55>", line 2, in write_videofile
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-54>", line 2, in write_videofile
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-53>", line 2, in write_videofile
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "C:\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 298, in write_videofile
    logger=logger)
  File "<decorator-gen-45>", line 2, in write_audiofile
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 210, in write_audiofile
    logger=logger)
  File "<decorator-gen-9>", line 2, in ffmpeg_audiowrite
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python36\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
    logger=logger):
  File "C:\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 86, in iter_chunks
    fps=fps, buffersize=chunksize)
  File "<decorator-gen-44>", line 2, in to_soundarray
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 127, in to_soundarray
    snd_array = self.get_frame(tt)
  File "<decorator-gen-11>", line 2, in get_frame
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Python36\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
    return self.make_frame(t)
  File "C:\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 297, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "C:\Python36\lib\site-packages\moviepy\audio\AudioClip.py", line 298, in <listcomp>
    if (part is not False)]
  File "<decorator-gen-11>", line 2, in get_frame
  File "C:\Python36\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Python36\lib\site-packages\moviepy\Clip.py", line 93, in get_frame
    return self.make_frame(t)
  File "C:\Python36\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 77, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
  File "C:\Python36\lib\site-packages\moviepy\audio\io\readers.py", line 186, in get_frame
    self.buffer_around(fr_max)
  File "C:\Python36\lib\site-packages\moviepy\audio\io\readers.py", line 240, in buffer_around
    array = self.read_chunk(chunksize)
  File "C:\Python36\lib\site-packages\moviepy\audio\io\readers.py", line 113, in read_chunk
    s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'

I was having the same problem as in here: https://github.com/Zulko/moviepy/pull/1185, "closing my files too early".

luckily I've found the issue already solved (thx tburrows13 for your overall assistance)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TowelDude picture TowelDude  Â·  3Comments

RahulPrasad picture RahulPrasad  Â·  4Comments

Netherdrake picture Netherdrake  Â·  5Comments

tburrows13 picture tburrows13  Â·  3Comments

Gicehajunior picture Gicehajunior  Â·  3Comments