Skip to content

Page 2 Streaming your Desktop on Twitch.com

Christophe NUNES edited this page Mar 22, 2017 · 2 revisions

How to make a Stream of your Desktop on Twitch.com

1rst Step

To understand this part, make sure you read the previous tutorial about how to make videos of your desktop with ffmpeg. If you don't, just take a moment to understand the input options of ffmpeg before continuing this tutorial.

Here we go

Previously, i shown you how to make a desktop video, and all the input options I used to make it. Now, we need to put output options to encode our desktop video into a supported format by RTMP (Real Time Messaging Protocol) to stream on Twitch.com.

RTMP uses flv (Flash Video) video format, MPEG4 video codec, and mp3 audio codec. Actually the configuration we need to make is something like :

DESKTOP----INPUT---->PULSE>----OUTPUT---->TWITCH

Let start streaming on Twitch.com

Just like previously we'll start with the input options, to finish with the output options, and the path where I want my streaming to be run. To stream on Twitch.com, you may need your Twitch Stream Key. You can find it easily in your account settings section. Let start streaming on Twitch.com :

ffmpeg -f x11grab -s 1920x1080 -r 30 -i :0.0 \
-f alsa -i pulse -vcodec libx264 \
-s 1280x720 -acodec libmp3lame -ac 2 \
-ab 128k -ar 44100 -threads 0 \
-f flv "rtmp://live.twitch.tv/app/your_stream_key"

Press Q to stop streaming.

Explanation

As we saw previously all input options, I'll only detail the output options in this section :

  • -s 1280x720 is the output video size. It means that the video will be streamed to twitch in 720p.

  • -acodec libmp3lame is an output mp3 codec. RTMP needs this codec to run.

  • -ac 2 audio channels (Stereo).

  • -ab 128k an audio bitstream filter.

  • -ar 44100 Audio Sampling Frequency. By default this value is 48000Hz. But RTMP doesn't support more than 44100.

  • -threads 0 processors used for encoding. By default 0 means that you allow ffmpeg to use all the power of your processor to encode if needed.

  • -f flv here I force the output format in flv, which is supported by RTMP. The rest is the path to Twitch. Just put you 'Twitch Stream Key` at the end to stream under your Twitch account.

WARNING : never give your Twitch Stream Key it's personnal.

Now, you just need to load Twitch.com page, looking for your account and watch what you're streaming. It works! Don't forget to stop streaming pressing Q on your terminal.

Finally

You know how to stream your Xserver (or desktop) on Twitch.com. In another Tutorial, I'll will show you how to configure Nginx to make a Streaming Server at house using VLC to watch the flow.

Thank you for attending this tutorial.

Best regards.

pixhub.