-1

I've been trying to figure out this problem the entire day. I'm trying to add a image at the bottom of every video in a directory.

Here is the error that i get after writing just 4 videos out of 100

 del self.reader
 AttributeError: reader
 Exception ignored in: <bound method VideoFileClip.__del__ of <moviepy.video.io.VideoFileClip.VideoFileClip object at 0x03D787B0>>

Here is how im trying to write the video

 video = CompositeVideoClip([clip1, clip2.set_duration(clip1.duration)])
 video = CompositeVideoClip("mixclip"+random.randint(999,999999)"+.mp4")
 del video
 del clip1
 del clip2

Edit: Posted a slightly wrong code which i made while i was testing and got a instant a -1. Changed it. But i still cannot find solution to this problem.

Edit2: Tested alot and figured it out. Fixed it by declaring clip2 duration before mixing it. Rewrote entire code didn't check what other changes i made but its working as intended now.

taijamen
  • 61
  • 1
  • 1
  • 7
  • 1
    You are calling `del video` but then you access `video` again in the next line `video.reader = None`. This cannot work. Also there might be an error in the `VideoFileClip` class. It calls `del self.reader`, but the exception indicates that this variable was never assigned. – pschill Mar 04 '17 at 19:14
  • @pschill I've tried both `video.reader = None` and `del video` without the other but it still crashes after 4 writes. – taijamen Mar 04 '17 at 19:19
  • You can try to use `clip1.reader = None` and `clip2.reader = None` before calling `CompositeVideoClip`. This should ensure that the variables are initialized before `clip1` and `clip2` are freed. Then use `video.reader = None` directly after both your lines `video = CompositeVideoClip(...)`. – pschill Mar 04 '17 at 19:28
  • Thanks @pschill I tried it but i'm still getting the same error. – taijamen Mar 04 '17 at 19:44
  • What are you trying to achieve with the second line? Apart from anything else, it is incorrect! If you remove it, everything works fine. – Tom Burrows Mar 04 '17 at 20:17
  • @Gloin Yeah that line was not intended to be used. I have a different function in use for that but it was a very long spintax string. – taijamen Mar 04 '17 at 22:38

1 Answers1

0

Update to the latest version at the GitHub repo or wait until the next moviepy update is pushed to PyPI, where this is fixed. (See these commits: one, two)

However, unless you tell us what the line

video = CompositeVideoClip("mixclip"+random.randint(999,999999)"+.mp4")

means, you may be coming across an underlying problem with your usage.

Just a side note: the above line has a couple of errors; change it to this:

video = CompositeVideoClip("mixclip" + str(random.randint(999, 999999)) + ".mp4")
Tom Burrows
  • 2,225
  • 2
  • 29
  • 46
  • Hey @Gloin thanks for the answer i somehow managed to get it working by testing different stuff. I guess moviepy is a bit buggy sometimes. That second line was not intended to be used. – taijamen Mar 04 '17 at 22:29
  • You could also try using Mplayer or OMX player. I found them to be much better than Movie.py.Omx is incredible but not available other CPU architectures except armhf – Seema Nair Jan 14 '20 at 10:44