本文介绍了YouTube即时串流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人我使用Logitech C920R实时分发到Youtube.

EveryoneI use the Logitech C920R to distribute live to Youtube.

命令如下.

#! / bin / sh
YOUTUBE_URL = "rtmp: //a.rtmp.youtube.com/live2"
KEY = "xxxx-yyyy-zzzz"
v4l2 - ctl --device = / dev / video0 - set - fmt - video = width = 1280, height = 720
ffmpeg - ar 44100 - ac 2 - f alsa - i hw: 1,0 - f v 4 l 2 - codec: v h 264 - framerate 30 - video-- size 1280 x 720 --itsoffset 0.5 \
-i / dev / video0 - copyyinkf - codec: v copy - codec: a aac - ab 128 k - g 10 - strict experimental \
-f flv $ YOUTUBE_URL / $ KEY
1> / dev / null 2> / dev / null &

运行此命令时,收到以下消息.

When I run this command, I get the following message.

[alsa @ 0xbbe770] ALSA buffer xrun.
[video4linux2,v4l2 @ 0xbc92d0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0xbbe770] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 329; changing to 500. This may result in incorrect timestamps in the output file.
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 361; changing to 500. This may result in incorrect timestamps in the output file.
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 393; changing to 500. This may result in incorrect timestamps in the output file.
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 429; changing to 500. This may result in incorrect timestamps in the output file.
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 461; changing to 500. This may result in incorrect timestamps in the output file.
[flv @ 0xc3d940] Non-monotonous DTS in output stream 0:0; previous: 500, current: 497; changing to 500. This may result in incorrect timestamps in the output file.
frame= 1112 fps= 31 q=-1.0 size=   14271kB time=00:00:42.16 bitrate=2772.7kbits/s speed=1.18x

这则讯息告诉我什么?

有什么需要改进的地方吗?

Is there anything to improve?

谢谢

推荐答案

您可以通过在摄像机输入之前添加 -use_wallclock_as_timestamps 1 来修复 DTS 错误,这同样适用于 thread_queue_size 错误,请在 -i 之前添加 -thread_queue_size 512 .

You can fix the DTS errors by adding -use_wallclock_as_timestamps 1 before your camera input, same goes for the thread_queue_size error, add -thread_queue_size 512 before -i.

例如

ffmpeg -use_wallclock_as_timestamps 1 -thread_queue_size 512 -i /dev/video0 -c copy test.mp4


Jann 的简要说明


A brief explanation from Jann

当FFMPEG对此进行免费承认时,错误:从比特率估算持续时间,这可能是不准确的.

As FFMPEG freely admits when it gives this error: Estimating duration from bitrate, this may be inaccurate.

这也使 -t 标志(持续时间)也可以是实时的,而不是也取决于fps的计算.

This also enables the -t flag (duration) to be real-time as well, instead of also being dependent on the fps calculation.

这篇关于YouTube即时串流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 19:41