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.
To start live streaming with FFmpeg, you have to download and install the software on your computer. You can choose the right installation method for your operating system from the three options above in this FFmpeg tutorial. At this point, you can also create a streaming channel on your video hosting platform.
After a lot of trial and error the solution below works pretty much perfectly. To make sure it runs 24/7 wrap it inside a service of some description.
This is with an up to date version of FFMPEG to include -stream_loop -1.
The background is an mp4 file.http://localhost:3888
= an audio stream.
ffmpeg -stream_loop -1 -i $MYPATH/background/$background \
-i http://localhost:3888 -filter:a "volume=$volume" \
-r 24 -g 48 -pix_fmt yuv420p -x264-params keyint=48:min-keyint=48:scenecut=-1 \
-s $size -b:v $bitrate -b:a 128k -ar 44100 -acodec aac \
-vcodec libx264 -preset superfast -bufsize 960k -crf 28 -threads 2 \
-f flv rtmp://a.rtmp.youtube.com/live2/$key
Config File:
# Config File
background=out.mp4
size=1280x720
bitrate=1500k
key=----KEY----
volume=0.5
EDIT -- Old Solution below
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.
The last code is excellent, but I am still getting error message regarding "video resolution" on youtube Live with the latest command. I fixed it by replacing:
yuv420p with yuvj420p
I probed jpg with ffprobe and it returned the above yuv420p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With