FFmpeg直播流 - 循环视频? [英] FFmpeg Live Stream - Loop Video?

查看:1378
本文介绍了FFmpeg直播流 - 循环视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FFmpeg流式传输一个视频循环到justin.tv?我设法循环图像序列并将其与音频中的行组合:

I am trying to stream a video loop to justin.tv using FFmpeg? I have managed to loop an image sequence and combine it with line in audio:


ffmpeg -loop 1 -i imageSequence%04d.jpg -f alsa -ac 2 -ar 22050 -ab 64k \
  -i pulse -acodec adpcm_swf -r 10 -vcodec flv \
  -f flv rtmp://live.justin.tv/app/<yourStreamKeyHere>

可以使用视频文件执行此操作吗?

Is it possible to do this with a video file?

推荐答案

绝对可能在最近的ffmpeg版本中,他们添加了一个-stream_loop标志,允许您根据需要循环输入多次。

Definitely possible. In the recent versions of ffmpeg they have added a -stream_loop flag that allows you to loop the input as many times as required.

从源重新生成pts,ffmpeg将在第一个循环后丢弃帧(因为时间戳将突然回到时间上)。为了避免这种情况,您需要告诉ffmpeg生成pts,以便在循环之间获得越来越大的时间戳。这是通过+ genpts调用(它必须在-i arg之前)完成的。

The gotcha is that if you don't regenerate the pts from the source, ffmpeg will drop frames after the first loop (as the timestamp will suddenly go back in time). To avoid this, you need to tell ffmpeg to generate the pts so you get an increasing timestamp between loops. This is done with the +genpts call (it has to be before the -i arg).

这是一个ffmpeg调用示例(用输入文件替换$ F)。此示例生成两个输出流,而-stream_loop -1参数告诉ffmpeg连续循环输入。在这种情况下的输出是类似的流广播摄取(MetaCDN),根据您的要求进行调整。

Here's an example ffmpeg call (replace $F with your input file). This example generates two output streams and the -stream_loop -1 argument tells ffmpeg to continuously loop the input. The output in this case is for a similar stream broadcast ingest (MetaCDN), adjust accordingly to your requirements.

ffmpeg -threads 2 -re -fflags +genpts -stream_loop -1 -i $F \
-s 640x360 -ac 2 -f flv -vcodec libx264 -profile:v baseline -b:v 600k -maxrate 600k -bufsize 600k -r 24 -ar 44100 -g 48 -c:a libfdk_aac -b:a 64k "rtmp://publish.live.metacdn.com/2050C7/dfsdfsd/lowquality_664?hello&adbe-live-event=lowquality_" \
-s 1920x1080 -ac 2 -f flv -vcodec libx264 -profile:v baseline -b:v 2000k -maxrate 2000k -bufsize 2000k -r 24 -ar 44100 -g 48 -c:a libfdk_aac -b:a 64k "rtmp://publish.live.metacdn.com/2050C7/dfsdfsd/highquality_2064?mate&adbe-live-event=highquality_"

这篇关于FFmpeg直播流 - 循环视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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