5

Alright so I've had Linux Ubuntu 12.04 for over a year now and I still don't know anything about it. That only thing I can do with it is use the internet. I want to start streaming games that I play on my computer to Twitch.tv., but I don't know how. All of the downloads are only for windows. I found a website that tells you how to do it, but since I know nothing about linux, I can't do it. I haven't been able to get past the first step yet. Can someone please give me a step by step tutorial on how to do it. Please do not think you are being to specific, because I am sure it will help me. The link to the website is this -http://www.creativetux.com/2012/11/streaming-to-twitchtv-with-linux.html

John
  • 51
  • 1
  • 1
  • 3
  • I got it working rather easily with OBS: https://www.gamingonlinux.com/articles/how-to-livestream-from-linux-to-twitch-a-simple-guide-to-being-awesome-on-linux.9257 – brandizzi Jun 12 '18 at 10:53

1 Answers1

6

You'll likely have to use ffmpeg or avconv and supply your Twitch.tv key which can be found here: http://www.twitch.tv/broadcast/dashboard/streamkey

Personally I use ffmpeg because avconv for some reason only displays my mouse on the stream when streaming from my laptop. A short example of this would be:

# stream key. You can set this manually.
STREAM_KEY=$(cat ~/.twitch_key)

# stream url. Note the formats for twitch.tv and justin.tv
# twitch:"rtmp://live.twitch.tv/app/$STREAM_KEY"
# justin:"rtmp://live.justin.tv/app/$STREAM_KEY"
STREAM_URL="rtmp://live.twitch.tv/app/$STREAM_KEY"

ffmpeg \
-f alsa -ac 2 -i "pulse" \
-f x11grab -s $(xwininfo -root | awk '/geometry/ {print $2}'i) -r "30" -i :0.0 \
-vcodec libx264 -s "640x360" -vpre "fast" \
-acodec libmp3lame -threads 6 -qscale 5 -b 64KB \
-f flv -ar 44100 "$STREAM_URL"

There are several gists out there that bundle the whole process into a more understandable script. I couldn't find one that I liked so I created my own based on the code above: https://gist.github.com/oseparovic/2db2aaa737cd37e7c068

You can see more about streaming to twitch.tv/justin.tv from ubuntu in this post: http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/

  • Thanks for your help! This looks like something I could use. However, when I try your example, or the one you have linked to, I get the following error: [X11grab indev @ 0x1d05440] Unable to parse option value "1920x1080+0+0" as image size [X11grab indev @ 0x1d05440] Error setting option video_size to value 1920x1080+0+0. (full log here) What to do? – Nickolai Leschov Dec 03 '13 at 13:34
  • What did you use for your INRES and OUTRES variables? It's complaining about your defined size of "1920x1080+0+0". Either this is the wrong format or you've got some special characters instead of double quotes. Make sure you have double quotes only in the script. – alexgophermix Dec 03 '13 at 18:30
  • INRES=$(xwininfo -root | awk '/geometry/ {print $2}'i), OUTRES="640x360", as in your example. (xwininfo) – Nickolai Leschov Dec 03 '13 at 18:59
  • Ah, it looks like $(xwininfo -root | awk '/geometry/ {print $2}'i) is returning an inproperly formatted size on your machine. Try manually setting your desired input resolution instead. For example: "1920x1080". If you need it to automatically pull the dimensions of your screen try this instead: $(xdpyinfo | grep 'dimensions:'|awk '{print $2}') – alexgophermix Dec 03 '13 at 20:01
  • 1
    This works. Now it goes "File for preset 'fast' not found ". How do I check which presets are there? – Nickolai Leschov Dec 03 '13 at 21:55
  • 1
    You may have a different version of ffmpeg. Newer versions of ffmpeg use the option -preset instead. Try to use -preset "fast" instead of -vpre "fast" – alexgophermix Dec 04 '13 at 18:51
  • Now the streaming works, when I additionally set -ar 44100: though Flash accepts other rates, twitch.tv only accepts 44100 in mp3. Would you please correct this example and the linked one? Also, how do I know what presets are out there? E.g. ubuntuguide talks about lossless_ultrafast... That one might be too much to actually use over WAN, but now that I got it working, I would like to optimize parameters to minimize CPU usage. – Nickolai Leschov Dec 27 '13 at 17:01
  • Unfortunately, I only get sounds recorded from my mic in the broadcast: any sound played by a running game or mplayer is not broadcast. How do I fix this? NB: script, warnings, full output, thread – Nickolai Leschov Dec 27 '13 at 18:11
  • Thanks for the correction, I've changed the post and the answer above. As for how to find the exact settings, I've found several different answers online none of which worked for my installation of ffmpeg. According to https://trac.ffmpeg.org/wiki/x264EncodingGuide the presets are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. As for how to get game sound, I'm not sure. I assume an input source is picked (I only used game sound) and the mic is probably an alternate source that's why you're not getting both. – alexgophermix Dec 27 '13 at 23:27