python 视频转 gif

1. 说明

需要 python 版本 >= 3.9


2. 使用 opencvPIL

  1. 用Python处理MP4与GIF格式互转,简单到爆!-python 视频转gif


3. 使用 moviepy

  1. 3行Python代码即可将视频转Gif-腾讯云开发者社区-腾讯云


4. 遇到的问题

4.1. module 'PIL.Image' has no attribute 'ANTIALIAS'

ANTIALIAS was removed in Pillow 10.0.0 (after being deprecated through many previous versions). Now you need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS.
(This is the exact same algorithm that ANTIALIAS referred to, you just can no longer access it through the name ANTIALIAS.)

使用 pip install Pillow==9.5.0 安装低版本即可。
参考:10.0.0 (2023-07-01) - Pillow (PIL Fork) 10.4.0 documentation


5. 相关

  1. 在 Mac 上截屏或录屏 - 官方 Apple 支持 (中国)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容