Created
July 25, 2013 05:39
-
-
Save anonymous/6077155 to your computer and use it in GitHub Desktop.
I found it hard to figure out how to stream to twitch.tv like i wanted to.. Here is a couple files with a guide on how to stream in linux. to start:: ./streamStart.sh &
to stop:: ./streamStop.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################# GUIDE ############################# | |
# | |
#===== install required modules ===== | |
#sudo apt-get install libavcodec-extra-53 | |
#sudo apt-get install libav-tools | |
#sudo apt-get install pavucontrol | |
#===== set to duplex ===== | |
#pavucontrol | |
##Go to Configuration tab, set to Analog Stereo Duplex | |
#===== set your twitch key ===== | |
##Create a file ".twitch_key" in your home folder, paste your key from twitch.tv/broadcast | |
#===== fill parameteres ===== | |
##Set INRES to area it will record on your screen (your LoL resolution) | |
##Set OUTRES to the resolution you want on your twitch stream (1280x720 is 720p) | |
##Set QUAL medium, fast, superfast (superfast for slow pc’s, medium for fast pc) | |
##go to http://obsproject.com/estimator | |
## Set FPS to recommend FPS | |
## Set BITRATE to recommended bitrate | |
## Set BUFSIZE to recommended buffer size | |
##Set AUDIODEVICE | |
#pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2 | |
# use the name of one with .monitor | |
#LOGLEVEL quiet OR info is for if you want to fill up your terminal with the log every second or not. | |
#===== Set position how you like it ===== | |
#The program will record on the top left corner $INRES pixels of your screen... | |
#I record only part of my screen, so i need to set an offset to which part i want to record... | |
# | |
#Example positions: | |
#records full screen | |
#(stream0, -i :0.0+0,0) | |
# | |
#records top left, excludes the panel bar: | |
#(stream0, -i :0.0+0,24) | |
# | |
#records bottom left corner.. yoffset = screen resolution Y - inres resolution Y (1200 - 720): | |
#(stream0, -i :0.0+0,480) | |
# | |
#records top right corner.. xoffset = screen resolution x - inres resolution Y (1900-1280): | |
#(stream0, -i :0.0+620,0) | |
############################# EXTRA SOURCES ############################# | |
#===== Add image overlay (for adverts / stream info) ===== | |
# | |
# Easiest way = Make an image in gimp with transparent background same size as your OUTRES | |
# | |
# change below line streamoverlay.png to whatever file name.ext your file is(gif if you want animated) | |
# add below line before the last -f line(take off the # before it):: | |
# -vf "movie=streamoverlay.png [wm];[in][wm] overlay=0:0 [out] \ | |
#===== Add webcam overlay (so people can see you being a dumbass) ===== | |
# | |
#NOT TESTED | |
#add below line | |
# | |
#-vf "movie=/dev/video0:f=video4linux2, scale=240:-1, fps, setpts=PTS-STARTPTS [movie]; [in][movie] overlay=main_w-overlay_w-2:main_h-overlay_h-2 [out]" | |
# | |
#First we set a name for the input to be used, in this case "movie". This is just a name, and you can choose whatever you want. The name is then defined with an input, in our case the webcam. | |
#Next option is used to scale the input down to a certain size. I use -1 to keep the original aspect ratio of the input, and set the width to 240 pixels. | |
#the option fps to force a constant bitrate. I did this because I had issued with the webcam lagging behind the desktop causing it to be out of sync. It might not be necessary, but I have it there to be safe. | |
#The last option is used to set the presentation timestamp on the input, starting with 0. | |
#setpts=PTS-STARTPTS | |
#This concludes the input options, and we close it of with [movie]; followed by [in][movie] | |
#Here we place the actual overlay settings. | |
#overlay=main_w-overlay_w-2:main_h-overlay_h-2 [out]" | |
#This places the input as an overlay 2 pixels from the bottom right, and 2 pixels from bottom. We close it off with [out] | |
############################# REFERENCES ############################# | |
# avconv documentation : http://libav.org/avconv.html | |
# Where i got the idea : https://gist.github.com/brodul/3178130 | |
# pulse audio names : http://www.oz9aec.net/index.php/gstreamer/365-pulseaudio-device-names | |
# image overlay : http://www.youtube.com/watch?v=89uH9r2BSMs | |
# webcam overlay : http://www.howtoforge.com/streaming-your-desktop-with-audio-and-webcam-overlay-in-a-browser-using-ffmpeg-crtmpserver-and-flowplayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#by twitch.tv/LOL1010101110 reddit.com/u/1010101110 | |
#running on linux mint 15 (should work on ubuntu) | |
# | |
#parameters | |
INRES="1280x720" # input resolution | |
OUTRES="1280x720" # Output resolution | |
FPS="30" # target FPS | |
QUAL="fast" # Quality preset | |
BITRATE="1000k" | |
BUFSIZE="1000k" | |
AUDIODEVICE="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor" | |
LOGLELVEL="quiet" | |
STREAM_KEY=$(cat ~/.twitch_key) | |
#functions | |
pactl load-module module-loopback | |
echo "stream starting..." | |
avconv \ | |
-f x11grab -s $INRES -r "$FPS" -i :0.0+0,24 \ | |
-f pulse -i $AUDIODEVICE \ | |
-vcodec libx264 -s $OUTRES -preset $QUAL \ | |
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b 1200k -bufsize 1200k \ | |
-f flv "rtmp://live.justin.tv/app/$STREAM_KEY" \ | |
-loglevel $LOGLELVEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#by twitch.tv/LOL1010101110 reddit.com/u/1010101110 | |
#running on linux mint 15 (should work on ubuntu) | |
# | |
#to run: | |
#./streamStop.sh | |
pactl unload-module module-loopback | |
killall avconv | |
echo "stream stopped" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment