General requirements
First PC:
First PC configuration (OBS settings)
Encoding:
Second PC configuration
You need to install NGINX with rtmp module: (the default nginx comes without rtmp support)
https://obsproject.com/forum/viewtopic.php?f=18&t=5873
https://obsproject.com/forum/viewtopic.php?f=18&t=2651
NGINX settings (/usr/local/nginx/conf/nginx.conf):
Description of some ffmpeg settings
Why you should send stream to "application live" and then push it to twitch?
If you send stream to twitch directly, it will lag. I have no idea why.
FFMpeg vs AVConv
Default ubuntu a/v converter is avconv. If you execute ffmpeg, ubuntu will execute avconv instead. It is not bad, but "real" ffmpeg and avconv has some different command line settings. For example -x264opts parameter not supported by avconv and I don't know how to define nal-hrd=cbr (it is Enable CBR padding in OBS) in avconv. I use "real" ffmpeg installed according to following guide http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide.
If someone know how to use avconv and correspond to new Twitch requirements, please let me know.
P.S. Sorry for my English :)
First PC:
- Intel Quicksync support
- RTMP server with NGINX under Ubuntu (ubuntu server virtual machine or standalone ubuntu server)
- Good CPU. I use Intel Core I7 3770K overclocked to 4500MHz. It allow to transcode 1080p with fast preset and 720p with medium preset. Free memory not important, because ubuntu use 200k maximum.
First PC configuration (OBS settings)
Encoding:
- Use CBR - enabled
- Use custom buffer size - enabled
- Max bitrate
- 25000 for 1080p
15000 for 720p
- 25000 for 1080p
- Buffer size - 7000. Buffer size more then 7000 can cause periodical disconnections from nginx.
- Streaming Service - custom
- Server - rtmp://second_pc_ip_address/transcode
- Set resolution and FPS according to your needs
- Use Quick Sync - enabled
Second PC configuration
You need to install NGINX with rtmp module: (the default nginx comes without rtmp support)
https://obsproject.com/forum/viewtopic.php?f=18&t=5873
https://obsproject.com/forum/viewtopic.php?f=18&t=2651
NGINX settings (/usr/local/nginx/conf/nginx.conf):
Code:
rtmp {
server {
listen 1935;
chunk_size 4000;
application transcode {
live on;
record off;
exec ffmpeg -re -i rtmp://localhost:1935/trans/$name -vcodec libx264 -preset medium -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -r 30 -b:v 2000k -maxrate 2000k -bufsize 2000k -threads 12 -s hd720 -sws_flags spline -acodec copy -f flv rtmp://localhost:1935/live/${name};
}
application live {
live on;
record off;
push rtmp://live-lhr.twitch.tv/app/twitch_key;
}
}
}
Description of some ffmpeg settings
- preset medium. Corresponding OBS option - x264 CPU Preset. Change according to your CPU.
- keyint=60. Corresponding OBS option - Keyframe Interval. Replace 60 by [OBS FPS setting]*2.
- nal-hrd=cbr. Corresponding OBS option - Enable CBR padding.
- force-cfr=1. Corresponding OBS option - Use CFR.
- r 30. Corresponding OBS option - FPS. Replace 30 by OBS FPS setting.
- b:v 2000k. Corresponding OBS option - Max Bitrate. Set according to your needs.
- maxrate 2000k. Corresponding OBS option - Max Bitrate. Set according to your needs.
- bufsize 2000k. Corresponding OBS option - Buffer size. Set to Max Bitrate or use custom buffer size according to your needs.
- threads 12. Set to 1.5 * logical processors, rounded down. In some cases ffmpeg/avconv can't detect CPU and use only one thread, so better to set it manually.
- s hd720. Resolution of target video. Also you can use following syntax: -s 1280x720. Video quality will be better in case you use downscaling by ffmpeg instead of first PS, because quicksync add too much sharpness into downscaled video. Remove this option in case you are streaming in 1080p.
- sws_flags spline. Downscale method. You can try "lanczos" method instead of "spline" as alternative. Remove this option in case you are streaming in 1080p.
- rtmp://live-lhr.twitch.tv/app/twitch_key. Replace by your favorite stream server and key. List of twitch.tv servers: http://bashtech.net/twitch/ingest.php
Why you should send stream to "application live" and then push it to twitch?
If you send stream to twitch directly, it will lag. I have no idea why.
FFMpeg vs AVConv
Default ubuntu a/v converter is avconv. If you execute ffmpeg, ubuntu will execute avconv instead. It is not bad, but "real" ffmpeg and avconv has some different command line settings. For example -x264opts parameter not supported by avconv and I don't know how to define nal-hrd=cbr (it is Enable CBR padding in OBS) in avconv. I use "real" ffmpeg installed according to following guide http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide.
If someone know how to use avconv and correspond to new Twitch requirements, please let me know.
P.S. Sorry for my English :)
Last edited by a moderator: