FFMPEG:如何以相同的编码独立地流式传输到多个输出 [英] FFMPEG: How to stream to multiple outputs with the same encoding independently

查看:380
本文介绍了FFMPEG:如何以相同的编码独立地流式传输到多个输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的信息流现在如何工作:

How my stream is working right now:

输入: 切换器程序,用于捕获相机和屏幕快照并进行不同的布局.该软件中的一个窗口是在ffmpeg命令行中用作输入的窗口.

Input: Switcher program that captures the camera and screen shots and make a different layouts. One of the windows from the software is the one used as Input in the ffmpeg command line.

输出: -Facebook(示例) -YouTube(示例)

Output: - Facebook (example) - Youtube (example)

在一开始,我认为可能最好创建两个不同的ffmpeg进程以独立地流到每个输出.问题是它使用了过多的CPU. 答案是编码一次并将其复制到不同的输出.好的,很好,它可以解决问题,但是如果输出之一失败了该怎么办?都失败了.

At the beginning, i thought that maybe could be better create two different ffmpeg processes to stream independently to each output. The problem was it uses too much CPU. The answer for it, was to encode one time and copy it to different outputs. Ok, great, it solves the problem, but what if one of the output fails? Both fail.

我正在尝试对两个输出进行编码,如果其中一个输出不可用,则另一个输出会很好.

I'm trying to make one encoding to two outputs and if one of these outputs is not available, the other keep going well.

有人有解决的办法吗?

谢谢!

推荐答案

我按照@LordNeckbeard所说的找到了解决方案.

I found the solution following what @LordNeckbeard said.

以下是示例代码:

  1. 保存本地文件
  2. 流式传输到您的服务器
  3. 流式传输到Facebook服务器

每个流都彼此独立,如果发生诸如Internet连接之类的事件,它将尝试每秒钟独立地恢复自身–将保存在本地,并尝试在Internet访问恢复时恢复–或目标服务器尚不可用以及何时可用回来后,它将重新开始流式传输过程):

Every stream is independent from the other and will try to recover itself independently every one second if something happened like internet connection–will save locally and try to recover when internet access came back–or destination server is not available yet and when it came back it will restart the streaming process):

-i ... -f tee "[onfail=ignore]'C:\Users\blablabla.mp4'|
[f=fifo:fifo_format=flv:drop_pkts_on_overflow=1:attempt_recovery=1:recovery_wait_time=1]rtmp://yourServer...|
[f=fifo:fifo_format=flv:drop_pkts_on_overflow=1:attempt_recovery=1:recovery_wait_time=1]"rtmp://facebook..."

这篇关于FFMPEG:如何以相同的编码独立地流式传输到多个输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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