unknown file extension: .mp4
Opened this issue · 1 comments
aloe8475 commented
Hi - love this package.
Just wondering why i'm getting the error: "unknown file extension: .mp4"
it's also happening for all other file formats i'm inputting.
Any ideas?
Specifically, the error occurs as follows:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~\anaconda3\lib\site-packages\PIL\Image.py in save(self, fp, format, **params)
2081 try:
-> 2082 format = EXTENSION[ext]
2083 except KeyError:
KeyError: '.mp4'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-114-513938de0b62> in <module>
64
65 animation = camera.animate()
---> 66 animation.save(r'C:\Users\61424\Documents\GitHub\CODE\Data\Figures\Functional Connectivity\'animation.mp4')
~\anaconda3\lib\site-packages\matplotlib\animation.py in save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs, progress_callback)
1154 progress_callback(frame_number, total_frames)
1155 frame_number += 1
-> 1156 writer.grab_frame(**savefig_kwargs)
1157
1158 # Reconnect signal for first draw if necessary
~\anaconda3\lib\contextlib.py in __exit__(self, type, value, traceback)
117 if type is None:
118 try:
--> 119 next(self.gen)
120 except StopIteration:
121 return False
~\anaconda3\lib\site-packages\matplotlib\animation.py in saving(self, fig, outfile, dpi, *args, **kwargs)
230 yield self
231 finally:
--> 232 self.finish()
233
234
\anaconda3\lib\site-packages\matplotlib\animation.py in finish(self)
575 self._frames[0].save(
576 self._outfile, save_all=True, append_images=self._frames[1:],
--> 577 duration=int(1000 / self.fps), loop=0)
578
579
~\anaconda3\lib\site-packages\PIL\Image.py in save(self, fp, format, **params)
2082 format = EXTENSION[ext]
2083 except KeyError:
-> 2084 raise ValueError("unknown file extension: {}".format(ext))
2085
2086 if format.upper() not in SAVE:`
ValueError: unknown file extension: .mp4
```
loomcode commented
You're having this problem because MP4 is not a format supported by pillow, the package being used to save the file. Simply put, the example given where save is called does not work. If you're okay with an animated gif and have imagemagic you can use:
anim.save('/home/blws1/Desktop/animated_gif.gif', writer='imagemagick')
.
A different writer might handle mp4.