I am using this script: http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/ to stream to Twitch. It works but I don't want to stream my microphone, only the computer audio. How should I change the script to achieve that?

1 Answer 1


Choosing computer audio


This can be done with PulseAudio and pavucontrol. From HOWTO: Proper Screencasting on Linux:

Install pavucontrol. Start recording with ffmpeg. Start pavucontrol. Go to the “Recording” tab and you’ll find ffmpeg listed there. Change audio capture from “Internal Audio Analog Stereo” to “Monitor of Internal Audio Analog Stereo“. Now it should record system and application audio instead of microphone.

This setting will be remembered. The next time you want to capture with ffmpeg, it will automatically start recording system audio. If you want to revert this, use pavucontrol again to change back to microphone input.


Alternatively, ALSA can capture system audio if your audio system supports a loopback device often labeled: Stereo Mix, Wave out mix, Mono Mix, or What U Hear. Check in alsamixer to see if you have one of these, but hardware loopback is not as common these days. Then refer to FFmpeg Wiki: Capturing Audio with ALSA for the proper syntax if your system supports this feature.

Otherwise I believe you can make a software loopback with ALSA, but I may be incorrect and have no experience with that.

Crappy script

The ffmpeg command in that awful, re-occurring script has some issues:

  • -preset should be used instead of -vpre
  • -qscale is ignored by libx264 (use -crf or -b:v)
  • The group of pictures is not set (use -g)
  • VBV should be used (use -maxrate and -bufsize)
  • The output may not use a compatible chroma subsampling scheme (use -pix_fmt yuv420p)
  • x11grab input should use -framerate, not -r
  • -threads 6 seems like an arbitrary number, and not everyone uses the same hardware. You should either use the default (by removing -threads, but it's "greedy"), or set an appropriate value that allows you to encode at a satisfactory rate and yet still allow enough juice to perform the other stuff that you're recording.

The command should be something like this instead:

ffmpeg \
-f alsa -ac 2 -i "$INAUD" \
-f x11grab -video_size "$INRES" -framerate "$FPS" -i :0.0 \
-vcodec libx264 -s "$OUTRES" -preset "$QUAL" -maxrate 1000k -bufsize 2000k -g 50 -pix_fmt yuv420p \
-acodec libmp3lame -ar 44100 -b:a 128k \
-f flv "$STREAM_URL"

Note: Do not just blindly use my example values for -maxrate, -bufsize, -g, and -b:a. You must adjust these according to your needs as described in Encoding for Streaming Sites with FFmpeg. Also see FFmpeg H.264 Video Encoding Guide.

  • I installed the control for PulseAudio and got it working by that!
    – rablentain
    Sep 3, 2014 at 20:45

You must log in to answer this question.

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