Close

Streaming script

A project log for growing mold in a cup of coffee leftovers

Specifically, streaming it to Twitch

aryaArya 09/03/2017 at 14:560 Comments
 INRES="1280x720" # input resolution
 OUTRES="640" # output resolution horizontal. vertical is calculated.
 FPS="7.75" # target FPS
 GOP="15.7" # i-frame interval, should be double of FPS,
 GOPMIN=$FPS # min i-frame interval, should be equal to fps,
 THREADS="2" # max 6
 CBR="1000k" # constant bitrate (should be between 1000k - 3000k)
 QUALITY="ultrafast"  # one of the many FFMPEG preset
#Audio actually doesn't work, I don't know why, but it's supposedly there
 AUDIO_SRATE="44100" 
 AUDIO_CHANNELS="1" #1 for mono output, 2 for stereo
 AUDIO_ERATE="96k" #audio encoding rate
 STREAM_KEY="sorry_to_disappoint_you" #your twitch stream key goes here
 SERVER="live-waw" #  http://bashtech.net/twitch/ingest.php for list
ffmpeg -y -f video4linux2 -s "1280x720" -r "$FPS" -i /dev/video0 -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -vf "scale=$OUTRES:-1,format=yuv420p" -acodec libmp3lame -f flv -preset $QUALITY -bufsize "500k" "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"

You can regulate camera parameters, like brightness, white balance and backlight compensation, in realtime (not interrupting the streaming pipeline) with v4l2-ctl, more on that here 

Discussions