官方网址:https://ffmpeg.p2hp.com/download.html#build-windows
![](https://img-blog.csdnimg.cn/img_convert/198d3393867d4a87e2f6ae62c9f34276.png)
![](https://img-blog.csdnimg.cn/img_convert/8ec353e78da4c962148a2869360ce319.png)
设置环境变量
![](https://img-blog.csdnimg.cn/img_convert/f36d5fc65d0e86c553be0fa5a18652b7.png)
![](https://img-blog.csdnimg.cn/img_convert/b2ed62701f1458f081620d870ed17083.png)
注意,需要添加到“系统变量”的“Path”条目中。
我们打开cmd命令行窗口,输入命令“ffmpeg –version”。窗口返回ffmpeg的版本信息,说明安装成功。接下来你就可以直接使用命令行执行ffmpeg命令进行各种媒体格式的转换了。
![](https://img-blog.csdnimg.cn/img_convert/9e33efab18aff3bcdab0b4abb01c9280.png)
python 调用ffmpeg
方法一:通过shell的方式
def video2File(video,framesDir,ffmpegCmd):
curVideoFrameOut=framesDir+"_%04d.jpg"
video2framesCmd = ffmpegCmd + " -i " + video + " -f image2 -vf fps=fps=30 -qscale:v 2 " +curVideoFrameOut
subprocess.call(video2framesCmd, shell=True)
if __name__ == "__main__":
ffmpegCmd = "ffmpeg//bin//ffmpeg.exe" #ffmpeg 路径
frameDir = r"\Desktop\image\im" #存放图像序列路径
videopath=r"\Desktop\20.mp4" #视频路径
video2File(videopath,frameDir,ffmpegCmd)
生成结果
在frameDir文件夹下面生成图片
![](https://img-blog.csdnimg.cn/img_convert/9cb244183016d2c494051babfd4161e9.png)