从多个视频文件到单个输出 [英] From multiple video files to single output

查看:94
本文介绍了从多个视频文件到单个输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我列出了数百种可能的视频文件.使用ffmpeg可以很容易地提取多个文件并将它们缝合在一起,形成单个视频输出,但这就是棘手的地方.

Let's say that I have a list of hundreds of possible video files. Using ffmpeg it's pretty easy to take multiple files and stitch them together to single video output, but that's where the things become tricky.

我正在寻找一种方法,使它们直播流,并动态添加视频,以便在视频流进行时进行排队.考虑类似 SSAI ,但用于整个视频.

I'm looking for a way to have them stream live and dynamically add videos to queue as stream goes on. Think of something like SSAI but for the whole video.

流直播在那里,所以我们在等待ffmpeg结束整个视频时没有延迟,而是希望尽快开始,并且还可以在其中选择下一个文件.在直播期间排队.

Stream live is there so we don't have a delay while waiting for ffmpeg to finish the whole video but rather start as soon as possible, and also so we could choose next files in queue during the live stream.

简化后,它看起来像这样:

Simplified, it would look something like this:

[v] [v] [v] [v] - stored video files, eg. on S3 

      [v] - chosen file

      | | 
      | | - during the live stream
      | |
      \ /
       V    
   _________             ___________              ___________
   \       /             |         |              ||       ||
    \     /    =====>    |         |    =====>    ||  |:>  ||
     \___/               |_________|              ||_______||
  Video queue              FFMPEG?                Live stream
                      Transcoding module?
                            Magic?

如果有任何区别,我将在Node.js中编写.

I'm writing this in Node.js if that makes any difference.

这甚至有可能吗?如果您需要更多信息,请询问,每个建议都将不胜感激!

Is this even possible? If you need any more information please ask away, and every suggestion is greatly appreciated!

推荐答案

执行此操作的基本方法是使用2级concat解复用器并循环顶级concat输入.

The basic method to do this is using 2 levels of the concat demuxer and looping the top-level concat input.

创建两个文本文件.

root.txt:

file nested.txt
file nested.txt

nested.txt:

nested.txt:

file current-video.mp4

然后

ffmpeg -re -f concat -safe 0 -stream_loop -1 -i root.txt -c copy {output options}

结束当前文件播放之前,用新文件名更新nested.txt.

Update nested.txt with new filename before the playing of the current file ends.

FFmpeg git版本>必须为2019年1月或4.2 +.

FFmpeg git version > Jan 2019 or 4.2+ is required.

所有文件必须具有使用相同编码的流​​.流的时基应该相同.为了保持同步,文件中所有流的持续时间应该相同.

All files must have streams with identical encoding. Timebase for streams should be the same. Duration of all streams within a file should be the same, in order to maintain sync.

这篇关于从多个视频文件到单个输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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