-
Streaming script
09/03/2017 at 14:56 • 0 commentsINRES="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
-
Technical decisions
09/03/2017 at 14:53 • 0 commentsWhy not have sound? First of all, it doesn't work in current setup for some reason. Second problem that the box is currently in the middle of our hackerspace's coworking room, and people expect some privacy there (in addition, not everybody that will come will know that there's a camera in that box on the desk, and it's streaming live).
Why Raspberry Pi? Once you get the hang of it and get a working ffmpeg command-line, it's a perfectly suitable device to stream RTMP to places like Twitch, Youtube or Facebook. You need to not be afraid of console, of course - but if you aren't, you save a lot of power and can make a really maintainable solution.
Why Logitech? It would be crazy not to use it, actually, their cameras are really high-quality while still being affordable, and the hardware supports various hardware encodings, has lots of parameters exposed for regulation, so it'd be stupid not to use a Logitech camera, from a technical standpoint.
Oh, and the 9V wall-wart connection goes through a capacitor bank, basically, I split PCB material two lines of copper with a cutting disk, then soldered on all kinds of capacitors I could find in our hackerspace.