Pillow: ValueError: unknown file extension: .mp4

Created on 14 May 2019  路  2Comments  路  Source: python-pillow/Pillow

I was playing around trying to create animations using circles. It's a simple code which moves a circle around in the frame.
I don't understand why it can't save the .mp4. I've conda installed ffmpeg and it's an updated version. Can somebody help me out with this?
(I'm using Windows 10)

anim.save('animation.mp4', fps=30, 
          extra_args=['-vcodec', 'h264', 
                      '-pix_fmt', 'yuv420p'])

Most helpful comment

fps and extra_args arguments look like they are from matplotlib's FFMpegWriter - https://matplotlib.org/api/_as_gen/matplotlib.animation.FFMpegWriter.html.

Hello Sir!
Yes, ffmpeg works for me now. I had conda installed ffmpeg but that doesn't work.
Downloading ffmpeg and adding it to the path works for me.

plt.rcParams['animation.ffmpeg_path'] ='C:\\Sushanti\\ffmpeg\\bin\\ffmpeg.exe'
FFwriter=animation.FFMpegWriter(fps=10, extra_args=['-vcodec', 'libx264'])
anim.save('plswork.mp4', writer=FFwriter)

All 2 comments

Pillow does not currently have an option to save MP4 files, so it makes sense that Pillow is reporting that this is an unknown file extension.

fps and extra_args arguments look like they are from matplotlib's FFMpegWriter - https://matplotlib.org/api/_as_gen/matplotlib.animation.FFMpegWriter.html. So I imagine that anim needs to be an FFMpegWriter object, rather than a Pillow image object. Here is a tutorial from Google if that is helpful - https://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/

fps and extra_args arguments look like they are from matplotlib's FFMpegWriter - https://matplotlib.org/api/_as_gen/matplotlib.animation.FFMpegWriter.html.

Hello Sir!
Yes, ffmpeg works for me now. I had conda installed ffmpeg but that doesn't work.
Downloading ffmpeg and adding it to the path works for me.

plt.rcParams['animation.ffmpeg_path'] ='C:\\Sushanti\\ffmpeg\\bin\\ffmpeg.exe'
FFwriter=animation.FFMpegWriter(fps=10, extra_args=['-vcodec', 'libx264'])
anim.save('plswork.mp4', writer=FFwriter)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

boskicthebrain picture boskicthebrain  路  4Comments

vytisb picture vytisb  路  4Comments

damianmoore picture damianmoore  路  4Comments

amithnikhade picture amithnikhade  路  4Comments

indirectlylit picture indirectlylit  路  4Comments