'FFMpegWriter not using the bitrate specified? Animation is very blurry
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:
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
