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

nginx configuration for outputting multiple resolutions? #15

Closed jellykells closed 6 years ago

jellykells commented 6 years ago

In the readme you imply that I can stream two separate resolutions/qualities to two separate services:

Please note that you also can encode your stream on the fly. If you want to stream to Youtube Gaming in 1080p at 60 FPS and on Twitch in 720p at 30 FPS, it's possible changing the Nginx configuration file.

I don't see any example of this however, and my attempts at modifying the nginx.conf file to accomplish it have failed. Any help?

Noxalus commented 6 years ago

Hello,

There is an example in the nginx.template.conf file (line 61).

By default, the resolution and quality transmit to the services is the one you broadcast from your PC, but there is an example where the stream is re-encoded on the fly by FFMpeg for Twitch:

# Send the default resolution and quality to Youtube
push rtmp://localhost/youtube/${name};

# Stream re-encoded by FFMpeg for Twitch
exec ffmpeg -i rtmp://localhost/$app/$name -c:v libx264 -preset veryfast -c:a copy 
    -threads 2
    -c:v libx264
    -profile:v main
    -preset:v veryfast
    -level 4.2
    -b:v 2000k
    -bufsize 2000k
    -maxrate 2000k
    -s 1280x720 -r 30
    -g 120 -keyint_min 60 -x264opts "keyint=120:min-keyint=120:no-scenecut"
    -tune zerolatency
    -c:a copy
    -f flv rtmp://localhost/twitch/${name};

FYI, back in the day, I struggled a lot to know what was wrong with my changes in the Nginx configuration file until I found a command that can tell you if your config is valid or not (here). It could be useful 😄

jellykells commented 6 years ago

Bless you, Noxalus.

You just saved me after 3 hours of troubleshooting torture. Not only did I not realize that section was only for Twitch, but I also have no idea how I screwed that part up... That command you linked probably would have helped.

I have it working with both Twitch and YouTube now. Thank you!