我正在使用python通过导入moviepy库创建一个程序,但收到以下错误:

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:\Users\hp pc\Anaconda3\envs\lib\site-packages\moviepy\video\io\VideoFileClip.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:\Users\hp pc\Anaconda3\envs\lib\site-packages\moviepy\video\io\ffmpeg_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:\Users\hp pc\Anaconda3\envs\lib\site-packages\moviepy\video\io\ffmpeg_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:\Users\hp pc\Anaconda3\envs\lib\subprocess.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:\Users\hp pc\Anaconda3\envs\lib\subprocess.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:\Users\hp pc\Anaconda3\envs\lib\subprocess.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

我通过运行以下命令解决了这个问题。

video_clip.reader.close()
video_clip.audio.reader.close_proc()

某种程度上python.exe是失败的,因为内部函数比如VideoFileClip在jupyter-notebook中报错

然后我关闭了所有东西并重新启动了,错误消失了,现在它正常工作。

链接来源:

http://www.voidcn.com/article/p-orifxkfo-btn.html
 

在VideoFileClip函数中获取“OSError:[WinError 6]句柄无效”的更多相关文章

  1. selenium 问题:OSError: [WinError 6] 句柄无效

    问题: 执行多个用例的时候,会抛出异常: File "xxxxxx.py", line 16, in get_driver driver = webdriver.Chrome(ex ...

  2. 【Selenium + Python】之OSError: [WinError 6] 句柄无效。

    问题描述:执行多个用例的时候,会抛出异常: Traceback (most recent call last): File "F:\Demo\pomGisStu\gis\test_case\ ...

  3. 在被调用函数中获取资源及C++中的引用

    #include <iostream> using namespace std; struct Teacher{ char name[64]; int age; }; //在被调用函数 获 ...

  4. 组件Slate教程 & UMG widget构造初始化函数中获取其内部组件

    转自:http://aigo.iteye.com/blog/2296218 目的:在自定义的Widget初始化完毕后,获取其内部的button.combo等UMG组件的C++指针. 这里我们新建了一个 ...

  5. vue 钩子函数中获取不到DOM节点

    原文链接:https://jingyan.baidu.com/article/f96699bbfe9c9d894f3c1b4b.html 两种解决方案: 1:官方解决方案: 受到 HTML 本身的一些 ...

  6. AngularJs在ng-click函数中获取代表当前元素的DOM对象

    html代码 <div ng-click="test($event)">111</div> Controllers.js $scope.test= func ...

  7. Android在OnCreate中获取控件的宽度和高度

    在Android中,有时需要对控件进行测量,得到的控件宽度和高度可以用来做一些计算.在需要自适应屏幕的情况下,这种计算就显得特别重要.另一方便,由于需求的原因,希望一进入界面后,就能得到控件的宽度和高 ...

  8. 使用python读取配置文件并从mysql数据库中获取数据进行传参(基于Httprunner)

    最近在使用httprunner进行接口测试,在传参时,用到了三种方法:(1)从csv文件中获取:(2)在config中声名然后进行引用:(3)从函数中获取.在测试过程中,往往有些参数是需要从数据库中获 ...

  9. SQL Server 中获取字符串拼音的标量函数实现

        工作中时常遇到字符串转换为拼音的需求.特别目前在各大网站平台都可以看到的基于拼音的查询功能.如果在查询中增加相应的拼音查询,就可以减少很多的因中文汉字完全输入的不便利,例如:当我要查询叫”郭德 ...

随机推荐

  1. 第15讲:嵌入式SQL语句(动态SQL)

    一.动态SQL概述 1. 静态SQL vs 动态SQL ①动态SQL是相对静态SQL而言的 ②静态SQL特点:SQL语句在程序中已经按要求写好,只需要把一些参数通过变量传递给SQL语句即可 specN ...

  2. Python入门基础学习(列表/元组/字典/集合)

    Python基础学习笔记(二) 列表list---[ ](打了激素的数组,可以放入混合类型) list1 = [1,2,'请多指教',0.5] 公共的功能: len(list1) #/获取元素 lis ...

  3. sql 代码优化

    1. where 执行顺序:右→左,筛选多的放右边:计算难度小的放右边,sql老版本(只在基于规则的优化器中有效,新版本基于代价不存在这个问题): 2. 少用子查询: 3. union快,表结构得一致 ...

  4. [C4W2] Convolutional Neural Networks - Deep convolutional models: case studies

    第二周 深度卷积网络:实例探究(Deep convolutional models: case studies) 为什么要进行实例探究?(Why look at case studies?) 这周我们 ...

  5. 求解LCA问题的几种方式

    求解LCA问题的几种方式 这篇随笔讲解图论中LCA问题(最近公共祖先)的几种求解方式及实现方法.LCA问题属于高级图论,所以希望读者学习过初级图论,知道图的一些基本知识,并懂得深搜算法的实现方式.这样 ...

  6. luoguP4770 [NOI2018]你的名字

    题意 不妨先考虑\(l=1,r=|S|\)的情况: 这时我们要求的其实是\(S,T\)的本质不同的公共子串数量. 首先对\(S\)建一个后缀自动机,同时对于每个\(T\),我们也建一个自动机. 根据后 ...

  7. docker 创建mysql容器并且绑定到本地navicat

    docker pull mysql docker run --name mysql -itd -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root1234 mysql do ...

  8. Linux学习笔记-第15天 还真是看书不如做实验

    自己多操作几遍还是有好处的,看跟练还是不一样.突然有点庆幸自己考试时间被改了.月底考试的话估计会有点悬.加油吧

  9. hdu 6465 线性变换高斯消元

    http://acm.hdu.edu.cn/showproblem.php?pid=6465 题意 给你三个点,再给你经过线性变换后的三个点,然后q次询问,给你一个点,需要你输出线性变换后的点 题解 ...

  10. vscode自定义vue模板代码

    File--->preference -->user Snippets-->搜索html.json 编辑 加入以下自定义代码内容 "Html5-Vue": { & ...