FFMPEG to Youtube Live

2019-03-31 13:18发布

问题:

I have an audio stream, im using ffmpeg to stream it to youtube live with an image as background with following command,

ffmpeg -loop 1 -i x.jpg -i http://xxx.xxx.xxx.xxxx:5305/stream -c:a aac -s 1280x720 -ab 128k -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/xxxxx

But im getting the following message on youtube,

YouTube is not receiving enough video to maintain smooth streaming. As such, viewers will experience buffering this cause buffering in the output stream.

Any one know how to fix it ?

Helps would be appreciated.

回答1:

So i have a solution.

ffmpeg -re -loop 1 -framerate 2 -i test1.jpg -i https://xxxxxxx:8443/live.ogg -c:a aac -s 2560x1440 -ab 128k -maxrate 2048k -bufsize 2048k -framerate 30 -g 60 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxxxx

The important parts are the

-re

at the start which deals with a buffering issue.
Then the

-framerate 2

between the "-loop 1" and the image. This works and i get a good clean high quality stream that does not buffer.

Hoped this helped!

Edit 1

ffmpeg -re -loop 1 -framerate 2 -i test1.jpg -i https://xxxxxxxxxxx:8443/live.ogg -c:a aac -s 2560x1440 -ab 128k -vcodec libx264 -pix_fmt yuv420p -maxrate 2048k -bufsize 2048k -framerate 30 -g 2 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxxxx

Ok So this updated version should fix almost all problems with the stream.

-vcodec libx264 -pix_fmt yuv420p

Changed to H.264 Codex Fixed that problem

-g 2

This fixes the final buffering issue.