一、安装ffmpeg环境
1、下载ffmpeg
2、解压缩并添加环境变量
选择计算机的版本,下载并解压缩,然后将bin目录添加到环境变量中
3、python安装ffmpeg
pip install ffmpy3 -i https://mirrors.aliyun.com/pypi/simple/
二、使用Python和ffmpeg下载视频
from ffmpy3 import FFmpeg def ffmpeg_path(inputs_path, outputs_path): ''' :param inputs_path: input file input dictionary format {file: operation} :param outputs_path: The output file is transferred to the dictionary format {file: operation} :return: ''' a = FFmpeg( executable='C:\\ffmpeg\\bin\\ffmpeg.exe', inputs={inputs_path: None}, outputs={outputs_path: '-c copy', } ) print(a.cmd) a.run() if __name__ == '__main__': ffmpeg_path('https://meng.wuyou-zuida.com/20200406/28920_d7b510c3/index.m3u8', 'demo.mp4')
注意:executable='C:\\ffmpeg\\bin\\ffmpeg.exe'
需要为自己电脑的ffmpeg.exe路径。【已解决】ffmpy3.FFExecutableNotFoundError: Executable ‘ffmpeg‘ not found
效果图