3

Using OBS and ffmpeg, I'm attempting to stream to both Facebook and Twitch at the same time. My current setup works, however the issue is it's a tad resource hungry.

FACEBOOK_KEY="123?ds=1\&s_l=1\&a=ggnore"
TWITCH_KEY="live_123_aBcEdFg"

ARGS="-c:v libx264 -preset medium -maxrate 3500k -bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv"

CMD="ffmpeg -re -listen 1 -i rtmp://127.0.0.1:5555"
CMD="$CMD $ARGS rtmp://live.twitch.tv/app/$TWITCH_KEY"
CMD="$CMD -r 30 $ARGS rtmp://rtmp-api.facebook.com:80/rtmp/$FACEBOOK_KEY"

eval $CMD

OBS settings are straight forward:

Video: 720p, 2500k bitrate, x264 encoding, 60FPS

Audio: 160k AAC.

I have two goals I'm trying to accomplish with the setup.

  1. For Twitch, ffmpeg should simply just be copying the source stream from OBS to Twitch without any conversion, as Twitch accepts what I'm passing from OBS.
  2. For Facebook, it should convert the FPS from 60 to 30, again with the minimal resource usage as Facebook accepts everything coming from OBS other then the FPS.

1 Answer 1

4
ffmpeg -listen 1 -i rtmp://127.0.0.1:5555 -c copy -f flv rtmp://twitch -c:v libx264 -preset medium -maxrate 3500k -bufsize 6000k -r 30 -pix_fmt yuv420p -g 60 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmp//:facebook
  • Don't use -re with live input streams. Documentation says that it may cause packet loss.

  • I changed -g 50 to -g 60 to better fit your 30 fps.

  • See the fifo muxer if you want to add options to attempt to recover the output in case of failure.

2
  • Fantastic! Thanks. Would you do anything else to the Facebook stream to reduce CPU usage? Anything you feel isn't needed?
    – Dustin
    Commented Jul 10, 2017 at 13:33
  • 2
    @Dustin Output 30 fps from OBS and then feed that to both Facebook and Twitch without re-encoding.
    – llogan
    Commented Jul 17, 2017 at 22:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .