# DDNet Live: Twitch spectates an online game

DevFeed: [DDNet Live: Twitch spectates an online game](<https://devfeed.tech/articles/ddnet-live-twitch-spectates-an-online-game-30812.md>)

Original publisher: [Read original article](<https://hookrace.net/blog/ddnet-live/>)

Published: 2016-01-09T23:00:00Z

Content type: tutorial

Language: en

Sources: [Dennis Felsing](<https://devfeed.tech/sources/dennis-felsing.md>)

Topics: [Twitch](<https://devfeed.tech/topics/twitch.md>), [FFmpeg (Fast Forward Moving Picture Experts Group)](<https://devfeed.tech/topics/ffmpeg.md>), [Streaming](<https://devfeed.tech/topics/streaming.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Hardware](<https://devfeed.tech/topics/hardware.md>), [intel](<https://devfeed.tech/topics/intel.md>), [Server](<https://devfeed.tech/topics/server.md>), [Nim](<https://devfeed.tech/topics/nim.md>)

Tags: [ffmpeg](<https://devfeed.tech/tags/ffmpeg.md>), [hardware](<https://devfeed.tech/tags/hardware.md>), [intel](<https://devfeed.tech/tags/intel.md>), [linux](<https://devfeed.tech/tags/linux.md>), [livestream](<https://devfeed.tech/tags/livestream.md>), [nim](<https://devfeed.tech/tags/nim.md>), [server](<https://devfeed.tech/tags/server.md>), [streaming](<https://devfeed.tech/tags/streaming.md>), [twitch](<https://devfeed.tech/tags/twitch.md>)

## AI overview

The article describes setting up a continuous DDNet livestream on Twitch from Linux using FFmpeg, a low-power J1900 home server, and a virtual display. It also explains using Twitch chat and DDNet FIFO command input so viewers can choose which players to spectate.

## Source excerpt

Last night I had an idea and implemented it, soo let's see what will happen. But first, the idea: Have a livestream [1] of DDNet running non-stop [2] that always shows some interesting [3] players on the server. The resulting livestream is running on Twitch. All the scripts are on Github 1. Livestream It's surprisingly simple to livestream from Linux to Twitch. Only FFmpeg is needed: #!/bin/sh INRES="1280x720" # input resolution FPS="30" # target FPS GOP="60" # i-frame interval, should be double of FPS, GOPMIN="30" # min i-frame interval, should be equal to fps, THREADS="2" CBR="2000k" # constant bitrate (should be between 1000k - 3000k) QUALITY="ultrafast" # one of the many FFMPEG preset AUDIO_SRATE="44100" AUDIO_CHANNELS="2" # 1 for mono output, 2 for stereo AUDIO_ERATE="96k" # audio encoding rate SERVER="live-fra" # http://bashtech.net/twitch/ingest.php for list source ./secret.sh ffmpeg -v 0 -f x11grab -s "$INRES" -r "$FPS" -i :0.0 \ -f alsa -i pulse -f flv -ac $AUDIO_CHANNELS \ -b:a $AUDIO_ERATE -ar $AUDIO_SRATE \ -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR \ -minrate $CBR -maxrate $CBR -vf "format=yuv420p"\ -preset $QUALITY -acodec libmp3lame -threads $THREADS \ -strict normal -bufsize $CBR \ "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY" This works pretty well, but takes quite a bit of CPU on my old computer. So instead I wanted to run it on my new server with a Haswell-era J1900 CPU. Possible ways to improve performance: Use an OpenGL recorder instead of x11grab Get Intel Quick Sync Video working for hardware H264 encoding 2. Running Non-Stop My server is a small and cheap ASRock Q1900-ITX: The nice part is that it's passively cooled and quite power efficient, drawing only 5 Watts in idle. This machine has been running as my home server for quite some time, but barely gets any action. Let's change that! The X server starts without problems even without any monitors attached, the only thing that's left to do is increasing the framebuffer size so that ou