2025年2月19日 星期三 甲辰(龙)年 腊月十九 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > Python

Python使用ffmpeg下载m3u8拼接为视频

时间:03-11来源:作者:点击数:26

一、安装ffmpeg环境

1、下载ffmpeg

ffmpeg官方地址

下载地址(github)

64位点击这里直接下载

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

在这里插入图片描述

效果图

在这里插入图片描述
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门