我正在使用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. [PHP] error_reporting(0)可以屏蔽Fatal error错误

    按照以前的印象,error_reporting(0)屏蔽不了php的Fatal error级别的错误.但是今天我遇到了一个问题才发现,它竟然可以屏蔽任何错误,包括Fatal error,浏览器会看不到 ...

  2. HTML&CSS基础-子元素和后代元素选择器

    HTML&CSS基础-子元素和后代元素选择器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.html源代码 <!DOCTYPE html> <html ...

  3. [排序][链表]Leetcode147 对链表进行插入排序

    思路: 插入算法的思想很简单,此题比较为链表数据类型,方便的是不用一个一个的向后移动元素,但是找到应该插入的位置相对麻烦,因为链表只有next指针,无法快速定位要插入的位置.在链表前面插入一个空指针, ...

  4. Linux shell 判断字符串为空等常用命令

    1.判断字符串为空 if [ -z "$str" ]; then echo "empty string" fi 2.判断文件是否存在 if [ -f /home ...

  5. 攻防世界web-NaNNaNNaNNaN-Batman

    先把附件下载下来,然后打开,一堆js乱码 把最后的eval修改成alert,再将文件后缀修改成html,用浏览器打开,乱码变正常了 之后把js代码对齐一下,这里用这个网站进行对齐 https://be ...

  6. Testng 简介

    Testng是一套开源测试框架,是从Junit继承而来,testng意为test next generation,主要有以下特性: annotations  注释,如 @test @BeforeMet ...

  7. MySQL 王者晋级之路

    3.2 Query Cache: 3.3 存储引擎 一.TokuDB的特点: – 插入性能加快20到80倍– 压缩数据减少存储空间– 数据量可扩展到几个TB– 不会产生索引碎片– 支持Hot Colu ...

  8. SOA案例分析浅谈

    SOA是英文 Service-Oriented Architecture 三个首字母单词的缩写,中文译为: 面向服务架构 ( SOA), SOA架构与 B/S . C/S 架构是目前最流行三种 Web ...

  9. luoguP5227 [AHOI2013]连通图(线性基做法)

    题意 神仙哈希做法. 随便找个生成树,给每个非树边赋一个值,树边的值为所有覆盖它的边的值得异或和. 删去边集使得图不联通当且即当边集存在一个子集异或和为0,可以用线性基. 证明的话好像画个图挺显然的 ...

  10. 循环队列c++代码

    #include <ros/ros.h> #include <string> #include <stdlib.h> #include <iostream&g ...