7

通过ffmpeg下载在线HTTP Live Stream视频

 2 years ago
source link: https://www.cnblogs.com/TianFang/p/15940478.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前几天收到一个老婆的在线视频下载的任务,上去看了下,是标准的h5的HTTP Live Stream解决方案:一个m3u8列表下分割了一大堆mp4切片,也就是说,要下载这种视频,需要如下几个步骤:

  1. 下载m3u8文件,获取mp4列表
  2. 下载所有mp4列表中的视频
  3. 将视频按顺序合并

本身没啥技术难度,我先手动的试了下,发现还是蛮费事的,便找了下有没有现成的解决方案,发现自己经常用的ffmpeg本身就支持这一功能:    

    ffmpeg -i https://xxx/xxx.m3u8 -acodec copy -vcodec copy output.mp4

这下就省事多了,直接一个脚本搞定所有的在线视频下载。

下载完视频后,又涉及到另一个问题了,视频裁减,同样可以用ffmpeg搞定。

    ffmpeg -i input.mp4 -ss 00:00:04 -to 00:04:16 -acodec copy -vcodec copy output.mp4
    -ss 开始时间
    -to 结束时间


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK