Youtube streaming using ffmpeg lowest configuration

Viewed 385

I am trying to stream a youtube live video. I have an mp3 file and a still image. I used following code for stream,

ffmpeg -y -loop 1 -i "still.jpg" -i "audio.mp3" " -c:v libx264 -preset ultrafast -pix_fmt yuv420p -minrate 6000k -maxrate 6000k -bufsize 12000k -b:v 6000k -r 30 -g 30 -keyint_min 60 -x264opts "keyint=60:min-keyint=60:no-scenecut" -s 1280x720 -tune zerolatency -b:a 128k -c:a aac -ar 48000 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/steam-key

It seems to be working but it has huge data transfer I think. I need to make bitrate and frame rate and other configuration to lowest. How to do it? And somewhere I found to add -re option which is missing here.

1 Answers

You set your minrate AND video bitrate to 6000k, which is huge for a still picture. You also set the framerate to 30, where 1 is enough. For the bitrate, I would go with constant rate factor. Which means it will use as much data it needs to produce a certain quality. This means that if the picture doesn't change, it doesn't need to add more bits. I'd also add a keyframe every 5 seconds in case people join in, and I removed the buffer because the stream is now so small, no buffers required.

Try to use the following command:

ffmpeg -y -loop 1 -i "still.jpg" -i "audio.mp3" " -c:v libx264 -pix_fmt yuv420p -crf 21 -r 1 -g 30 -keyint_min 5 -x264opts "keyint=5:min-keyint=5:no-scenecut" -s 1280x720 -tune zerolatency -b:a 128k -c:a aac -ar 48000 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/steam-key
Related