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

Created on 2 Oct 2019  路  4Comments  路  Source: Zulko/moviepy

MoviePy while effective, sometimes it's very unpredictable and unreliable. Once it runs, next time it fails. I was just running a concat on subvideos, now the same script is failing. I don't recall changing anything. Am I doing anything wrong?!

    for i in range(parts):
        cl = VideoFileClip(bestFilename[i])
        start = 0
        end = float(length / parts)
        s = cl.subclip(start, end);
        sub.append(s)
        cl.reader.close()
    final = concatenate([sub[0], sub[1].crossfadein(.5), sub[2].crossfadein(.5), sub[3].crossfadein(.5)], padding=-1, method="compose")
    final.write_videofile(output+filename+".mp4",audio=False)
    self.make_frame = lambda t: self.reader.get_frame(t)
AttributeError: 'NoneType' object has no attribute 'get_frame'

bug

Most helpful comment

Hi!

Whenever you are reporting bugs and crashes, you need to give the entire error traceback, not just the last 2 lines. I have very little way of knowing where in moviepy the error happened from what you've given me.

However, I think if you remove the cl.reader.close() line it will work. Look at https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/VideoFileClip.py#L123 for what happens when you call close on the VideoFileClip: it sets self.reader to None, which would explain why in the error it is complaining that self.reader has NoneType (ie is set to None).

Sidenote: concatenate() is depracated; use concatenate_videoclips() instead. https://github.com/Zulko/moviepy/blob/master/moviepy/video/compositing/concatenate.py#L15 vs https://github.com/Zulko/moviepy/blob/master/moviepy/video/compositing/concatenate.py#L124

All 4 comments

Hi!

Whenever you are reporting bugs and crashes, you need to give the entire error traceback, not just the last 2 lines. I have very little way of knowing where in moviepy the error happened from what you've given me.

However, I think if you remove the cl.reader.close() line it will work. Look at https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/VideoFileClip.py#L123 for what happens when you call close on the VideoFileClip: it sets self.reader to None, which would explain why in the error it is complaining that self.reader has NoneType (ie is set to None).

Sidenote: concatenate() is depracated; use concatenate_videoclips() instead. https://github.com/Zulko/moviepy/blob/master/moviepy/video/compositing/concatenate.py#L15 vs https://github.com/Zulko/moviepy/blob/master/moviepy/video/compositing/concatenate.py#L124

Thanks. Yeah I thought it's a famous error so didn't bother including the whole trace.
I'm posting another similar error

Don't worry, I thought the exact same thing when I started programming/using Github 3 years ago. However, even if it was a famous/known error we can only guess that it is the same problem that is causing it without the traceback.

This should be fixed in #1185, MoviePy v1.0.3. Feel free to create a new issue if you are still experiencing this problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keikoro picture keikoro  路  4Comments

Swiffers picture Swiffers  路  4Comments

PyB1l picture PyB1l  路  3Comments

Netherdrake picture Netherdrake  路  5Comments

bobozar picture bobozar  路  4Comments