Youtube live streaming

2019-07-23 04:49发布

问题:

Everyone I use the Logitech C920R to distribute live to Youtube.

The commands are as follows.

#! / 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

What is this message telling me?

Is there anything to improve?

Thank you

回答1:

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.

e.g.

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

A brief explanation from Jann

This forces FFMPEG (a hack really) to use the recording SYSTEM's timestamp instead of trying to compute the time of the movie depending on the number of fps it detects. FPS detection is notoriously inaccurate, for instance.

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

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



标签: ffmpeg