Last active
September 5, 2017 16:08
-
-
Save daniel-j/7938003 to your computer and use it in GitHub Desktop.
Livestream raspicam to RTMP server with audio (optional, uses an ALSA capture device).
This file contains hidden or 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
#!/bin/bash | |
# created by djazz (@daniel_hede) | |
# Video | |
width=640 | |
height=360 | |
fps=25 | |
vkbits=128 | |
# Audio | |
aenable=0 | |
adevice=hw:1,0 | |
akbits=128 | |
channels=1 | |
samplefreq=22050 | |
# Output | |
container=flv | |
url="rtmp://192.168.0.111/live/test" | |
# For Twitch/Justin.tv: | |
# url="rtmp://live.justin.tv/app/live_XXXXXXXXXX" | |
if [ $aenable -eq 0 ] | |
then | |
/opt/vc/bin/raspivid -w $width -h $height -fps $fps -t 0 -b ${vkbits}000 -o - | \ | |
ffmpeg \ | |
-f h264 -r $fps -i - \ | |
-threads 1 \ | |
-c:v copy \ | |
-loglevel info \ | |
-f $container "$url" | |
else | |
/opt/vc/bin/raspivid -w $width -h $height -fps $fps -t 0 -b ${vkbits}000 -o - | \ | |
ffmpeg \ | |
-f h264 -r $fps -i - \ | |
-f alsa -ar $samplefreq -ac $channels \ | |
-i $adevice -c:a libmp3lame -b:a ${akbits}k \ | |
-threads 1 \ | |
-c:v copy \ | |
-loglevel info \ | |
-f $container "$url" | |
fi | |
# For streaming raw audio from a named pipe | |
# -f s16le -ar 22050 -ac 2 \ | |
# -i alsa.raw -c:a copy \ | |
# For streaming a mp3 stream over HTTP | |
# -i http://hiveradio.net:8000/stream -c:a copy \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment