Created
July 2, 2018 21:44
-
-
Save ulitiy/e8add469ceaa4eea463eafe7e01d6f27 to your computer and use it in GitHub Desktop.
ffmpeg stream to youtube
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
#!/bin/bash | |
pid_file="/var/run/stream.pid" | |
case "$1" in | |
restart) | |
/etc/init.d/stream stop | |
/etc/init.d/stream start | |
;; | |
start) | |
rm $pid_file | |
v4l2-ctl --set-ctrl power_line_frequency=1 | |
ffmpeg \ | |
-f v4l2 -input_format mjpeg -video_size 1280x720 -framerate 25 -i /dev/video0 -thread_queue_size 1024 \ | |
-f lavfi -ac 1 -thread_queue_size 1024 -i anullsrc=cl=mono -flags +global_header -ab 128k -acodec libmp3lame -ar 44100 \ | |
-r 25 -g 75 -maxrate 3M -bufsize 4M -preset faster -vcodec libx264 \ | |
-f flv "rtmp://a.rtmp.youtube.com/live2/#################" &> /home/ulitiy/stream.log & | |
# cd5d-7vmf-4dpq-5xe4 | |
#-f lavfi -ac 2 -thread_queue_size 1024 -i "aevalsrc=0:d=100" -flags +global_header -ab 32k -acodec libmp3lame -ar 44100 \ | |
#-f alsa -ac 2 -thread_queue_size 1024 -i default -flags +global_header -ab 32k -acodec libmp3lame -ar 44100 \ | |
ch_pid=$! | |
echo "Start HLS: ffmpeg = $ch_pid"; | |
echo $ch_pid > $pid_file | |
;; | |
stop) | |
echo "Stop transcoding"; | |
kill `cat $pid_file` | |
;; | |
*) | |
echo "Usage: /etc/init.d/thisBashScript {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 | |
echo $pid_file | |
#ffmpeg -f v4l2 -itsoffset -0.5 -i /dev/video0 -thread_queue_size 1024 -f alsa -ac 1 -thread_queue_size 1024 -async 1 -i hw:9 -flags +global_header -ab 128k -acodec libmp3lame -ar 44100 -threads 6 -b:a 32k -bufsize 512k -s 1280x720 -preset faster -crf 22 -vcodec h264 -pix_fmt yuv420p -g 30 -vb 3000k -profile:v baseline -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/##############" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment