Skip to content

下载 m3u8 视频

一般网站视频文件都是以 blob 开头的,这个文件名是随机的,并不能真正获取到视频源地址,需要通过开发者工具或者浏览器插件(猫抓)获取到真正的 m3u8 地址。


下载 m3u8 的几种方法

  • N_m3u8DL-CLI 可下载 m3u8,前提是需要获取到 m3u8 文件
  • ffmpeg -i https://example.com/index.m3u8 -c copy -bsf:a aac_adtstoasc ./out.mp4,这个 m3u8 文件可在网页中使用开发工具---网络,然后在 filter 中输入 "m3u8" 即可找到。
  • 自己写脚本,通过爬虫解析网页获取到 m3u8 文件,然后读取 m3u8 里的所有 ts 文件,通过 you-get 或者其它下载工具,进行多线程下载,然后用 ffmpeg 合并 ts 文件为一个完整的视频,Demo 代码

you-get 下载 bilibili 视频

you-get 无法使用:

报错:

bash
you-get: [error] oops, something went wrong.
you-get: don't panic, c'est la vie. please try the following steps:
you-get: (1) Rule out any network problem.
you-get: (2) Make sure you-get is up-to-date.
you-get: (3) Check if the issue is already known, on
you-get: https://github.com/soimort/you-get/wiki/Known-Bugs
you-get: https://github.com/soimort/you-get/issues
you-get: (4) Run the command with '--debug' option,
you-get: and report this issue with the full output.

解决方案:

you-get 无法下载高清视频

参考