Noxalus / Multi-Streaming-Server

A NGINX server with RTMP module to send video streaming to multiple services simultaneously (Youtube, Twitch, Dailymotion, Hitbox, Beam, etc...).
173 stars 41 forks source link

Vagrant twitch #8

Closed dwbstreet closed 6 years ago

dwbstreet commented 8 years ago

Noxalus, thanks so much for all of your time.

I sincerely appreciate you assisting me in getting the Virtual Box up and running!

My connection to twitch is encountering problems. It is connecting fine, but the encoder is not functioning properly. This is the message I am receiving: Max keyframe interval is currently at 8.0 seconds. Please set it to 2 seconds. The broadcast is not set to constant bitrate (CBR). [Current average: 1896 kbps, current max: 2559.124 kbps"

Noxalus commented 8 years ago

Hello,

If you also use FFMpeg to encode your stream to Twitch (like in the default configuration of this project), you can specify the keyframe using some additional paramaters:

-x264-params keyint=60:no-scenecut=1

The value of keyint should be the max keyframe you want * FPS. So for a max keyinterval of 2 and with a stream locked to 30 FPS, the value of keyint will be 2 * 30 = 60.

(source)

Same thing to use a constant bitrate, you need to use a new parameter:

-x264opts bitrate=3500:vbv-maxrate=3500:vbv-bufsize=116

(source)

At the end, you should have something like that in your Nginx configuration file:

exec ffmpeg -i rtmp://localhost/$app/$name -c:v libx264 -preset veryfast -c:a copy 
    -b:v 3500k 
    -bufsize 3500k
    -maxrate 3500k 
    -s 1280x720 -r 30
    -x264-params keyint=60:no-scenecut=1:bitrate=3500:vbv-maxrate=3500:vbv-bufsize=116
    -f flv rtmp://localhost/twitch/$name;

I didn't test the solutions here and I'm not an expert of FFMpeg. I advise you to look at the FFMpeg official documentation if you still have some problems with your stream encoding.

Let me know if it works as expected ;)

dwbstreet commented 8 years ago

Thanks so much. After updating the config the twitch account showed excellent at first connection. After I refreshed the page, this changed to acceptable and listed the same issues (CBR not constant, Keyframe 8). I don't understand..

dwbstreet commented 8 years ago

Here is a screenshot of the twitch video statistics directly: image I have both my original feed from OBS and the Vagrant config set to 30fps, not 60. I noticed that today, as well.