Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Twitch.tv script for streaming
#! /bin/bash
# originaly from http://tinyurl.com/twitch-linux from taladan
# www.youtube.com/user/taladan
# gist created by brodul
INRES="1280x800" # input resolution
#OUTRES="1024x640" # Output resolution
OUTRES="800x500" # Output resolution
FPS="30" # target FPS
QUAL="medium" # one of the many FFMPEG preset on (k)ubuntu found in /usr/share/ffmpeg
# If you have low bandwidth, put the qual preset on 'fast' (upload bandwidth)
# If you have medium bandwitch put it on normal to medium
# Write your key in a file named .twitch_key in your home directory
STREAM_KEY=$(cat ~/.twitch_key) # This is your streamkey generated by jtv/twitch found at: http://www.justin.tv/broadcast/adv_other
avconv \
-f x11grab -s $INRES -r "$FPS" -i :0.0 \
-f alsa -ac 2 -i pulse \
-vcodec libx264 -s $OUTRES -preset $QUAL \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b 712000 -bufsize 512k \
-f flv "rtmp://live.justin.tv/app/$STREAM_KEY"
@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Mar 10, 2013

Unrecognized option 'preset'
Failed to set value 'medium' for option 'preset'

Can't find usr/share/ffmpeg either on Linux Mint 14 KDE Edition. :(

ghost commented Mar 10, 2013

Unrecognized option 'preset'
Failed to set value 'medium' for option 'preset'

Can't find usr/share/ffmpeg either on Linux Mint 14 KDE Edition. :(

@nchu

This comment has been minimized.

Show comment Hide comment
@nchu

nchu May 29, 2013

Unrecognized option 'preset'
Failed to set value 'medium' for option 'preset'

nchu commented May 29, 2013

Unrecognized option 'preset'
Failed to set value 'medium' for option 'preset'

@marco-kretz

This comment has been minimized.

Show comment Hide comment
@marco-kretz

marco-kretz Oct 25, 2013

@evropi:

install the package namend "ffmpeg"

@nchu

install 'libavcodec-extra-53'

@evropi:

install the package namend "ffmpeg"

@nchu

install 'libavcodec-extra-53'

@gorkipt

This comment has been minimized.

Show comment Hide comment
@gorkipt

gorkipt Nov 7, 2013

[x11grab @ 0x9caf20] device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1920 height: 1080
[x11grab @ 0x9caf20] Could not open X display.
:0.0: Input/output error 

what now ? =S

gorkipt commented Nov 7, 2013

[x11grab @ 0x9caf20] device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1920 height: 1080
[x11grab @ 0x9caf20] Could not open X display.
:0.0: Input/output error 

what now ? =S

@Kranium31

This comment has been minimized.

Show comment Hide comment
@Kranium31

Kranium31 Nov 22, 2013

sound is way a head of the video, anyone know what command i can add to keep the audio in sync?

sound is way a head of the video, anyone know what command i can add to keep the audio in sync?

@noccy80

This comment has been minimized.

Show comment Hide comment
@noccy80

noccy80 Dec 11, 2013

@Kranium31 try tweaking the buffer size (-bufsize) up and down and see if that makes any difference.

noccy80 commented Dec 11, 2013

@Kranium31 try tweaking the buffer size (-bufsize) up and down and see if that makes any difference.

@mjrb

This comment has been minimized.

Show comment Hide comment
@mjrb

mjrb Dec 23, 2013

when i am broadcasting it dosnt show the video it just sits there and says loading

mjrb commented Dec 23, 2013

when i am broadcasting it dosnt show the video it just sits there and says loading

@CuBiC3D

This comment has been minimized.

Show comment Hide comment
@CuBiC3D

CuBiC3D Jan 3, 2014

Same problem as @mjrb. Video keeps loading on different devices. Tried streaming on fast @ 1024x640 with 10Mbit/s uplink on 13.10.

CuBiC3D commented Jan 3, 2014

Same problem as @mjrb. Video keeps loading on different devices. Tried streaming on fast @ 1024x640 with 10Mbit/s uplink on 13.10.

@ckdarby

This comment has been minimized.

Show comment Hide comment
@ckdarby

ckdarby Jan 13, 2014

This long longer works by the way.

Your live stream will just show a gray box but if you record the video it'll have the video contents.

Example:
http://www.twitch.tv/testubuntu/b/494211210

ckdarby commented Jan 13, 2014

This long longer works by the way.

Your live stream will just show a gray box but if you record the video it'll have the video contents.

Example:
http://www.twitch.tv/testubuntu/b/494211210

@KurinPawpad

This comment has been minimized.

Show comment Hide comment
@KurinPawpad

KurinPawpad Feb 2, 2014

To fix the 'Unrecognized option 'preset' Failed to set value 'medium' for option 'preset'' bug, change 'preset' to 'pre' on line 22, and change 'fast' or 'medium' to 'libx264-fast' or 'libx264-medium' respectively.

To fix the 'Unrecognized option 'preset' Failed to set value 'medium' for option 'preset'' bug, change 'preset' to 'pre' on line 22, and change 'fast' or 'medium' to 'libx264-fast' or 'libx264-medium' respectively.

@xSidewinderx

This comment has been minimized.

Show comment Hide comment
@xSidewinderx

xSidewinderx Apr 9, 2014

I had this working before not sure what changed, but on the stream it says live but all I see is a gray screen and "loading video" any help?

I had this working before not sure what changed, but on the stream it says live but all I see is a gray screen and "loading video" any help?

@ual002

This comment has been minimized.

Show comment Hide comment
@ual002

ual002 Jun 22, 2014

I'm a complete linux newbie. This worked great. What about the audio, including mic?

EDIT: Nevermind, the mic works, what about any gameplay audio?

ual002 commented Jun 22, 2014

I'm a complete linux newbie. This worked great. What about the audio, including mic?

EDIT: Nevermind, the mic works, what about any gameplay audio?

@xros

This comment has been minimized.

Show comment Hide comment
@xros

xros Jun 24, 2015

You may try this one for noobies. :) https://github.com/xros/livestreamer

xros commented Jun 24, 2015

You may try this one for noobies. :) https://github.com/xros/livestreamer

@balthazar

This comment has been minimized.

Show comment Hide comment
@balthazar

balthazar Jun 23, 2017

Anyone got around the loading issue?

Anyone got around the loading issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment