![](/img/trans.png)
[英]“OSError: [Errno 22] Invalid argument” error when trying to bind to a socket
[英]Trying to save an animation gives error: OSError: Error saving animation to file (cause: [Errno 22] Invalid argument)
我正在尝试保存 animation,但出现错误:
OSError:将 animation 保存到文件时出错(原因:[Errno 22] 无效参数)标准输出:b''标准错误:b''。 将日志记录级别设置为 DEBUG 可能有助于重新运行。
我已经安装了 ffmpeg 并且还在我的代码中添加了它的路径。 如果我添加print(animation.writers.list())
,它也会在列表中给出“ffmpeg”,所以我确信我的计算机可以找到正确的文件。
在我的代码顶部,我有:
import matplotlib.pyplot as plt
plt.rcParams['animation.ffmpeg_path'] = 'C:/FFmpeg/bin/ffmpeg.exe'
在保存 animation 时,我有:
SubplotAnimation_1 = SubplotAnimation(F_vector, eta_atm, Pkid, Tb_sky)
Writer = animation.FFMpegWriter(fps=20, metadata=dict(artist='Me'), extra_args=['--verbose-debug'])
file_string = r'C:/Users/Esmee/Documents/Animations/animation_tryout.mp4'
print(file_string)
SubplotAnimation_1.save(file_string, writer=Writer)
我在字符串前面添加了r
,所以file_string中的/a
没有问题。 文件夹 C:/Users/Esmee/Documents/Animations/ 肯定存在,所以这也不成问题。 我也试过
Writer = animation.writers['ffmpeg']
mywriter = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
但它也不起作用。
我查看了animation 保存错误, 如何克服这个关键字错误和没有可用的 Moviewriters ,但它们都没有解决我的问题。
有谁知道是什么问题? 提前致谢!
最后,下面的代码起作用了:
Writer = animation.FFMpegWriter(fps=20, metadata=dict(artist='Me'))
file_string = r'C:/Users/Esmee/Documents/Animations/animation_tryout.mp4'
SubplotAnimation_1.save(file_string, writer=Writer)
我认为animation.FFMpegWriter
命令中的参数extra_args=['--verbose-debug']
(我从另一个解决方案中得到)导致程序崩溃。 我没有更改程序顶部的导入语句中的任何内容。
我希望这篇文章可以帮助任何有类似问题的人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.