-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSError: [WinError 6] The handle is invalid... concatenating clips #823
Comments
I'm guessing that what is happening is that you are trying to load the same clip twice. Can you run this to test my hypothesis?
I expect it will fail with the same error as you had before. After you've ran this report the results back here and I can help you avoid it. Thanks. |
I ran the test and there were no errors present.
The folder I'm pulling data from has 65,000 unique clips in it. The chances of it pulling the same one are slim to none. |
Oh ok. This is definitely a bug and it has come up loads with windows and moviepy. Unfortunately there isn't a definitive solution. Try calling |
Since I posted this I have added this function
Then I call I have a theory that running another moviepy program simultaneously is causing the issue. |
Ok. In which case I'd suggest doing your movie stuff inside a process. This will delete all references when the function ends. Note that I haven't tested this code.
|
Final code below... I tried using the This doesn't eliminate the WinError 6, but when it happens the process ends and another one takes its place. Thanks for your help! I'll mark this as closed.
|
hi
python3.6 |
I have the same question. |
@lily1720 @shahla69 This issue got fixed with Python 3.8. Try if upgrading to 3.8 solves WinError 6 for you. It did for me. |
Hello,
|
This "win 6" error happens only with process from multiprocessing but never occurs when using thread from threading..
Spec : any alternate solution for the time being ? |
@hackydunk @tburrows13 and anyone who will read this thread in the future: the problem is that you have to close all opened files implicitly if you are using Windows. So, if you have some code that creates videos: list[VideoFileClip] = read_videos()
images: list[ImageClip] = read_images()
audios: list[AudioFileClip] = read_audios()
do_the_suff_you_need(videos, images, audio)
for clip in videos + images + audios:
clip.close() There is the snippet from the source code of the def close(self):
"""
Release any resources that are in use.
"""
# Implementation note for subclasses:
#
# * Memory-based resources can be left to the garbage-collector.
# * However, any open files should be closed, and subprocesses
# should be terminated.
# * Be wary that shallow copies are frequently used.
# Closing a Clip may affect its copies.
# * Therefore, should NOT be called by __del__().
pass |
Expected Behavior
I want to choose clips randomly from a directory and then concatenate them into a compilation. My code works fine a random number of times before inevitably failing with a WinError 6 seen below.
Actual Behavior
Steps to Reproduce the Problem
Specifications
I'm using PyCharm for development
The text was updated successfully, but these errors were encountered: