如何使用ffmpeg批量/顺序下载m3u8文件? [英] How can I batch/sequentially download m3u8 files using ffmpeg?

查看:324
本文介绍了如何使用ffmpeg批量/顺序下载m3u8文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Mac上使用以下工具单独下载m38u播放列表:

I'm currently downloading m38u playlists individually using the following on Mac:

ffmpeg -i <"URL with m3u8"> -codec copy output.ts

如果我要处理多个文件,当前我是在单独的终端窗口中进行处理的.

If I want to do multiple files, I currently do it from separate Terminal windows.

我想做的是在单个实例中告诉ffmpeg例如从.txt文件中提取URL并依次下载,每个URL都有一个顺序的输出名称(将它们都适合在同一输出文件夹中).

What I would like to do is, in a single instance, tell ffmpeg to e.g. take URLs from a .txt file and download them in sequence, with a sequential output name for each (fine for them to all go in same output folder).

m3u8文件中的示例代码:

Sample code from m3u8 file:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:9
#EXTINF:8.333333,
segment00000.ts
#EXTINF:8.333333,
segment00001.ts
#EXTINF:8.333333,
segment00002.ts
#EXTINF:5.000000,
segment00003.ts
#EXTINF:8.333333,
segment00004.ts
#EXTINF:8.333333,
segment00005.ts

我当然已经安装了自制软件-我是新手,所以不确定这是否意味着我正在积极地使用"它来管理软件包

I certainly have homebrew installed - I'm a novice, so unsure whether that means I'm actively 'using' it to manage packages

带有m3u8地址列表的文件当前位于/Users/username/Downloads/m38u hold list.txt,如下所示:

The file with the list of of m3u8 addresses is currently located at /Users/username/Downloads/m38u hold list.txt and looks like this:

https://streaming.imvbox.com/media/2825/1280x800/1280x800.m3u8
https://streaming.imvbox.com/media/2298/1280x800/1280x800.m3u8
https://streaming.imvbox.com/media/2822/1280x800/1280x800.m3u8
https://streaming.imvbox.com/media/2821/1280x800/1280x800.m3u8
https://streaming.imvbox.com/media/2820/1280x800/1280x800.m3u8
https://streaming.imvbox.com/media/2088/1280x800/1280x800.m3u8

但是到目前为止,该文件只是存储链接的地方-除了复制链接以外,我什么都没用.

But so far this file is simply a place to store the links - I haven't used it anything other than to copy the links from.

推荐答案

因此,我将以下内容保存为您的 HOME 目录中的 grabAll :

So, I would save the following in your HOME directory as grabAll:

#!/bin/bash

HoldList="/Users/username/Downloads/m38u hold list.txt"

index=0
while read line ; do
    echo ffmpeg -i $line -codec copy output-${index}.ts
    ((index=index+1))
done < "$HoldList"

注意:如果您使用 TextEdit ,请确保单击菜单选项 Format -> Make Plain Text

Note: If you use TextEdit, make sure to click menu option Format->Make Plain Text

然后您可以启动终端并运行:

Then you can start Terminal and run:

bash grabAll

,然后查看它是否正在生成所需的命令类型.它目前不执行任何操作,只是在屏幕上说出将要执行的操作.如果看起来不错,您只需要从第三行到最后一行删除 echo 一词,然后再次运行即可.

and see if it is generating the type of commands you want. It doesn't currently do anything, it just says on the screen what it would do. If it looks good, you just need to remove the word echo from the 3rd to last line and run it again.

示例输出

ffmpeg -i https://streaming.imvbox.com/media/2825/1280x800/1280x800.m3u8 -codec copy output-0.ts
ffmpeg -i https://streaming.imvbox.com/media/2298/1280x800/1280x800.m3u8 -codec copy output-1.ts
ffmpeg -i https://streaming.imvbox.com/media/2822/1280x800/1280x800.m3u8 -codec copy output-2.ts
ffmpeg -i https://streaming.imvbox.com/media/2821/1280x800/1280x800.m3u8 -codec copy output-3.ts
ffmpeg -i https://streaming.imvbox.com/media/2820/1280x800/1280x800.m3u8 -codec copy output-4.ts
ffmpeg -i https://streaming.imvbox.com/media/2088/1280x800/1280x800.m3u8 -codec copy output-5.ts

这篇关于如何使用ffmpeg批量/顺序下载m3u8文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆