FFmpeg可以串联来自其他域的文件吗? [英] Can FFmpeg concatenate files from a different domain?

查看:212
本文介绍了FFmpeg可以串联来自其他域的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将各种.ts视频剪辑连接为一个视频,然后将视频转换为.mp4文件.我知道我可以制作一个格式如下的.txt文件:

I'm attempting to concatenate various .ts video clips into one video and then convert the video into an .mp4 file. I know I can make a .txt file formatted like so:

file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

然后像这样将它们连接起来:

and then concatenate them like so:

ffmpeg -f concat -i mylist.txt -c copy all.ts

然后像这样转换文件:

ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4

我的问题是,我的.txt文件可以是来自另一个域的url吗?例如:

My question is, can my .txt file be urls from another domain? e.g.:

http://somewebsite.com/files/videoclip1.ts
http://somewebsite.com/files/videoclip2.ts
http://somewebsite.com/files/videoclip3.ts

或者,我是否首先必须下载所有这些剪辑,将它们本地存储在我的域中,然后创建指向它们的.txt文件?我正在使用PHP.谢谢.

Or, do I first have to download all these clips, store them locally on my domain, then make a .txt file pointing to them? I'm using PHP. Thanks.

推荐答案

是的,这是可能的.请注意,在以下示例中,在测试时,我使用您问题中的网址和文件名.在测试时,我在自己的Web服务器上使用了一些测试文件.

Yes, this is possible. Note that in the following examples I use the urls and filenames from your question, when testing I used some test files on my own web server.

尝试使用您提供的示例文本文件将给出一个非常清晰的错误消息:

Trying this with the example text file you provided will give a pretty clear error message:

[concat @ 0x7f892f800000]第1行:未知关键字' http://somewebsite.com/files/videoclip1.ts

mylist.txt:处理输入时发现无效数据

mylist.txt: Invalid data found when processing input

可以很容易地通过在mylist.txt中重新引入'file'关键字来解决:

This is easily fixed by re-introducing the 'file' keyword in mylist.txt:

file 'http://somewebsite.com/files/videoclip1.ts'
file 'http://somewebsite.com/files/videoclip2.ts'
file 'http://somewebsite.com/files/videoclip3.ts'

该更新的文件将给出不同的错误消息:

That updated file will give a different error message:

[concat @ 0x7fa467800000]不安全的文件名' http://somewebsite.com/files/videoclip1. ts '

mylist.txt:不允许操作

mylist.txt: Operation not permitted

其原因是ffmpeg默认情况下不允许http-url.可以通过在您的ffmpeg调用之前 -i参数

The reason for this is that ffmpeg will not allow http-urls by default. This can be bypassed by including the -safe 0 argument in your ffmpeg call before the -i argument:

ffmpeg -f concat -safe 0 -i mylist.txt -c copy all.ts

这可能在您的安装中立即可用,在我的系统上这又给出了另一条错误消息:

This might work out of the box on your installation, on mine this gave another error message:

[http @ 0x7faa68507940]协议'http'不在白名单'file,crypto'上!

[http @ 0x7faa68507940] Protocol 'http' not on whitelist 'file,crypto'!

[concat @ 0x7faa69001200]无法打开' http://somewebsite.com/files/videoclip1. ts '

[concat @ 0x7faa69001200] Impossible to open 'http://somewebsite.com/files/videoclip1.ts'

mylist.txt:无效的参数

mylist.txt: Invalid argument

这是因为在我的安装中,ffmpeg的默认协议白名单仅包含filecrypto.为了也允许http协议,我们需要在命令中显式提供允许的协议白名单.事实证明,还需要tcp:

This is because, on my installation, ffmpeg's default protocol whitelist only includes file and crypto. To allow the http protocol as well, we need to explicitly provide the allowed protocols whitelist in the command. As it turns out, tcp is also required:

ffmpeg -f concat -safe 0 -protocol_whitelist file,http,tcp -i mylist.txt -c copy all.ts

这使我的安装程序可以下载并连接视频文件.

This allowed my installation to download and concatenate the video files.

这篇关于FFmpeg可以串联来自其他域的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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