本文介绍了获取“OSError: [WinError 6] 句柄无效";在 VideoFileClip 函数中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过导入 moviepy
库来使用 python
创建程序,但出现以下错误:
I am creating a program using python
by importing moviepy
library, but getting following error:
from moviepy.editor import VideoFileClip
white_output = 'videos/testVideo.mp4'
clip1 = VideoFileClip("videos/testVideo.mp4")
OSError Traceback (most recent call last)
<ipython-input-40-f49638833528> in <module>()
1 white_output = 'videos/testVideo.mp4'
----> 2 clip1 = VideoFileClip("videos/testVideo.mp4")
3 white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!
4 get_ipython().magic('time white_clip.write_videofile(white_output, audio=False)')
C:Usershp pcAnaconda3envslibsite-packagesmoviepyvideoioVideoFileClip.py in __init__(self, filename, has_mask, audio, audio_buffersize, audio_fps, audio_nbytes, verbose)
53 # Make a reader
54 pix_fmt= "rgba" if has_mask else "rgb24"
---> 55 reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
56 self.reader = reader
57 # Make some of the reader's attributes accessible from the clip
C:Usershp pcAnaconda3envslibsite-packagesmoviepyvideoioffmpeg_reader.py in __init__(self, filename, print_infos, bufsize, pix_fmt, check_duration)
30
31 self.filename = filename
---> 32 infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
33 self.fps = infos['video_fps']
34 self.size = infos['video_size']
C:Usershp pcAnaconda3envslibsite-packagesmoviepyvideoioffmpeg_reader.py in ffmpeg_parse_infos(filename, print_infos, check_duration)
236 popen_params["creationflags"] = 0x08000000
237
--> 238 proc = sp.Popen(cmd, **popen_params)
239
240 proc.stdout.readline()
C:Usershp pcAnaconda3envslibsubprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
840 pass_fds=()):
841 """Create new Popen instance."""
--> 842 _cleanup()
843 # Held while anything is calling waitpid before returncode has been
844 # updated to prevent clobbering returncode if wait() or poll() are
C:Usershp pcAnaconda3envslibsubprocess.py in _cleanup()
503 def _cleanup():
504 for inst in _active[:]:
--> 505 res = inst._internal_poll(_deadstate=sys.maxsize)
506 if res is not None:
507 try:
C:Usershp pcAnaconda3envslibsubprocess.py in _internal_poll(self, _deadstate, _WaitForSingleObject, _WAIT_OBJECT_0, _GetExitCodeProcess)
1257 """
1258 if self.returncode is None:
-> 1259 if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
1260 self.returncode = _GetExitCodeProcess(self._handle)
1261 return self.returncode
OSError: [WinError 6] The handle is invalid
请告诉我一个解决方法.
Please let me know a workaround.
推荐答案
不知何故 python.exe
失败了,因为像 VideoFileClip
这样的内部函数在 VideoFileClip
中出错代码>jupyter-notebook.
Somehow python.exe
was failing and because of that internal function like VideoFileClip
was giving error in jupyter-notebook
.
然后我关闭了所有东西并重新启动,瞧,错误消失了,现在工作正常.
Then I closed everything and restarted back and voila, error was gone and it's working fine now.
这篇关于获取“OSError: [WinError 6] 句柄无效";在 VideoFileClip 函数中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!