ffmpegwriter未使用指定的比特率?动画很模糊
我正在使用matplotlib
's funAnimation
以及ffmpegwriter
尝试将模拟动画写入文件。我想保存它的高质量版本,但是当我增加bittrate
作者的值时,它创建的.mp4
的实际比特率似乎会增加在离散的步骤中达到相当低的值,之后它不再增加。
我的代码大致是:
dpi = 96
fig = plt.figure(figsize=(width/dpi, height/dpi), dpi=dpi)
anim = FuncAnimation(fig, myAnimation, frames=100, interval=1, blit=True)
writer = animation.FFMpegWriter(fps=10, bitrate=<some number>)
anim.save('MyAnimation.mp4', writer=writer)
动画只有200x200px,所以我觉得拥有高质量的视频应该不是问题,但是我似乎无法获得足够高的比特率。对于我的代码中指定的以下比特率,文件属性中显示的实际比特率是:
BR In Code => Actual BR (kbps)
-1 / None => 13
100 => 58
1000 => 76
10000 => 76
比特率似乎根本不太跟踪,并且根本不会超过76kbps
。在此比特率时,该视频仍然很模糊。
我需要做什么来增加比特率,否则视频文件的质量?
另外,是否有更好的视频格式/作者可以用于此目的?特别是广泛支持的人,因此我可以将其嵌入网站或将其上传到YouTube或类似的内容。
编辑:
更具体地说明了这个问题,相邻像素正在混合在一起,从而使外观变得模糊。以下IMGUR专辑显示了具有不同设置的几个示例:
https://i.sstatic.net/bco9q.jpg
这些包括plt.show()
,默认比特率,“高”比特率的视图中的视图,我刚刚尝试的其他方法是增加DPI。虽然结果要好得多,但执行时间几乎增加了一倍,因此我想避免使用它。
为了使其看起来不错,必须添加实际上“像素艺术”的内容似乎很愚蠢,但是我想这是信号处理方法MPEG使用的工件,这就是为什么我怀疑其他文件格式可能是最好的。这样的小框动画解决方案。如果我想做一个1920*1080动画,那么模糊可能不太可能是一个问题。
I am using matplotlib
's FunAnimation
as well as FFMpegWriter
to try to write a simulation animation to a file. I'd like to save a high quality version of it, but when I increase the bitrate
value of the writer, the actual bitrate of the .mp4
it creates seems to increase in discrete steps up to a fairly low value after which it doesn't increase any more whatsoever.
My code is roughly:
dpi = 96
fig = plt.figure(figsize=(width/dpi, height/dpi), dpi=dpi)
anim = FuncAnimation(fig, myAnimation, frames=100, interval=1, blit=True)
writer = animation.FFMpegWriter(fps=10, bitrate=<some number>)
anim.save('MyAnimation.mp4', writer=writer)
The animation is only 200x200px so I feel like it shouldn't be a problem to have a high quality video, but I can't seem to get a high enough bitrate. For the following bitrates specified in my code, the actual bitrate shown in the files properties are:
BR In Code => Actual BR (kbps)
-1 / None => 13
100 => 58
1000 => 76
10000 => 76
The bitrate doesn't seem to track very well at all, and won't go above 76kbps
at all. The video is still badly blurry at this bitrate.
What do I need to do to increase the bitrate or else the quality of the video file?
Alternatively, is there a better video format/writer to use for this purpose? Specifically one that is broadly supported so I could embed it in a website or upload it to YouTube or something like that.
Edit:
To be more specific about the issue, neighboring pixels are being blended together, resulting in a blurry look. The following imgur album shows several examples with different settings:
https://i.sstatic.net/BCO9q.jpg
These include the view in the figure window from plt.show()
, default bitrate, a "high" bitrate, and something else I just tried which was to increase the dpi. While the results are much nicer it also nearly doubled the execution time so I'd like to avoid it.
It seems silly to have to upscale what is effectively "pixel art" in order for it to look good, but I guess this is an artifact of the signal processing approach mpeg uses, which is why I suspect a different file format might be the best solution for small framed animations like this. If I wanted to do a 1920*1080 animation the blurring would probably be less of an issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论