summaryrefslogblamecommitdiffstats
path: root/roles/stream/templates/restream.sh
blob: 4577cde3aca07620556105e14633438051516446 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                       
                                               

                                                                           





                                                                                        



                                     

                            










                                                              


                              
#!/bin/bash
# {{ ansible_managed }}
# echo $$ > /tmp/restream-{{ item[1].key }}.pid
MOUNT={{ item[0].stream_url }}/{{ item[1].key }}   # rtmp://..../stream_key
LOGLEVEL="${LOGLEVEL:-24}"
while true; do
    ffmpeg -re -loglevel $LOGLEVEL \
					 -reconnect_at_eof 1 \
					 -reconnect_streamed 1 \
           -fflags +genpts -i http://localhost:{{ icecast_port }}/{{ item[1].source }} \
					 -cluster_size_limit 2M \
           -cluster_time_limit 5100 \
           -b:v 1M \
           -crf 30 \
           -g 125 \
           -threads 4 \
           -vcodec libx264 \
					 -preset:v ultrafast \
		       -tune zerolatency \
					 -maxrate:v 256k \
					 -bufsize:v 512k \
					 -acodec libmp3lame \
					 -ac 2 \
					 -b:a 96k \
					 -preset:a ultrafast \
					 -maxrate:a 96k \
					 -bufsize:a 192k \
		       -tune zerolatency \
           -f flv $MOUNT
    sleep 5 # in case of error
done