0

I am making a program that cuts out certain parts of a video in MoviePy. I have a list like this:

myList = [[3, 7], [11, 15]]

and want to remove those times from the video - so it would remove the 3-7 second, and the 11-15 second, etc.

This list has lots of values in it, so if I try this:

    for x in myList:
        videoObject = videoObject.cutout(x[0], x[1])

it works but eventually comes up with a RecursionError: maximum recursion depth exceeded while calling a Python object which is probably because I am calling that function a lot of times.

Is there any easy way I can do this?

  • What do you want to achieve. What is the expected result? – Mirronelli Apr 01 '21 at 19:13
  • You see the list above. Those values are seconds. So I want to cut out between 3 and 7 seconds (get rid of that), and also cut out between 11 and 15 seconds, etc. – SomeoneLudo Apr 02 '21 at 08:37
  • I am not getting something here. How would a method on a list cut out something in a related video? Did you want to call a method on a video object? – Mirronelli Apr 02 '21 at 12:00
  • Sorry just realised what you meant I fixed it – SomeoneLudo Apr 02 '21 at 12:29
  • I don't know how your object works, since you do not mention what type it is. However any time you modify an object by removing something from it in a loop you should think about what happens after each iteration. Doesn't the first instance of a removal logically shift all the remaining timings? If so, removing in a reverse order, might help. Remove the highest time spot first, going back as you progress. This way any new timing does not shift those that precede it. – Mirronelli Apr 02 '21 at 14:17
  • I understand your point here - I didn't think of that! I'll give it a go and see if it works – SomeoneLudo Apr 02 '21 at 21:25

0 Answers0