获取"TypeError:每当尝试对Moviepy中的剪辑运行WRITE_VIDEOFILE时,必须为实数,而不是NoneType&QOOT;

Getting quot;TypeError: must be real number, not NoneTypequot; whenever trying to run write_videofile to a clip in moviepy(获取quot;TypeError:每当尝试对Moviepy中的剪辑运行WRITE_VIDEOFILE时,必须为实数,而不是NoneTypeQOOT;)
本文介绍了获取"TypeError:每当尝试对Moviepy中的剪辑运行WRITE_VIDEOFILE时,必须为实数,而不是NoneType&QOOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例代码:

from moviepy.editor import *
clip = VideoFileClip('video.mp4')
clip.write_videofile('video2.mp4', fps=30)

在显示以下消息后,表示正在构建和编写视频

Moviepy - Building video video2.mp4.
Moviepy - Writing video video2.mp4

出现以下错误消息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersUserAnaconda3libsite-packagesdecorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:UsersUserAnaconda3libsite-packagesmoviepydecorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:UsersUserAnaconda3libsite-packagesdecorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:UsersUserAnaconda3libsite-packagesmoviepydecorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "C:UsersUserAnaconda3libsite-packagesdecorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:UsersUserAnaconda3libsite-packagesmoviepydecorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "C:UsersUserAnaconda3libsite-packagesmoviepyvideoVideoClip.py", line 300, in write_videofile
    ffmpeg_write_video(self, filename, fps, codec,
  File "C:UsersUserAnaconda3libsite-packagesmoviepyvideoioffmpeg_writer.py", line 213, in ffmpeg_write_video
    with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,
  File "C:UsersUserAnaconda3libsite-packagesmoviepyvideoioffmpeg_writer.py", line 88, in __init__
    '-r', '%.02f' % fps,
TypeError: must be real number, not NoneType

每当我尝试在Moviepy中对任何类型的剪辑执行write_videofile时,都会出现这种情况。奇怪的是,昨天完全相同的代码对我起作用了,但今天突然不再起作用了。是否有任何建议是什么原因以及如何解决此问题?

推荐答案

尝试升级您的电影包

pip install moviepy --upgrade

我在1.0.0版本中遇到了同样的问题。升级到1.0.3已修复该问题。

这篇关于获取&quot;TypeError:每当尝试对Moviepy中的剪辑运行WRITE_VIDEOFILE时,必须为实数,而不是NoneType&QOOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Leetcode 234: Palindrome LinkedList(Leetcode 234:回文链接列表)
How do I read an Excel file directly from Dropbox#39;s API using pandas.read_excel()?(如何使用PANDAS.READ_EXCEL()直接从Dropbox的API读取Excel文件?)
subprocess.Popen tries to write to nonexistent pipe(子进程。打开尝试写入不存在的管道)
I want to realize Popen-code from Windows to Linux:(我想实现从Windows到Linux的POpen-code:)
Reading stdout from a subprocess in real time(实时读取子进程中的标准输出)
How to call type safely on a random file in Python?(如何在Python中安全地调用随机文件上的类型?)