Reiniciando proceso ffmpeg usando monit

Tema en 'GNU/Linux' comenzado por MikrotikPeru, 15 de Diciembre de 2019.

  1. MikrotikPeru

    MikrotikPeru Active Member

    Configurar en el Monit /etc/monit/conf.d/ffmpeg.conf:

    Código:
    check process ffmpeg with pidfile /var/run/ffmpeg.pid
        start program = "/bin/sh -c 'ulimit -n 65536; /etc/init.d/ffmpeg start'"
        stop program = "/bin/sh -c 'kill `cat /var/run/ffmpeg.pid`'"
    
    Código:
    #!/bin/sh
    
    pid_file="/var/run/ffmpeg.pid"
    
    case "$1" in
    restart)
        /etc/init.d/ffmpeg stop
        /etc/init.d/ffmpeg start
            ;;
    
    start)
        rm $pid_file
            /usr/bin/ffmpeg -i http://1.2.5.4:1935/test/playlist.m3u8 -pix_fmt yuv420p -vsync 1 -vcodec libx264 -r 23.976 -threads 0 -b:v: 1024k -bufsize 1216k -maxrate 1280k -preset medium -profile:v high -tune film -g 48 -x264opts no-scenecut -acodec aac -b:a 192k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f flv "rtmp://127.0.0.1:1935/live/stream" &
        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/ffmpeg {start|stop|restart}"
             exit 1
             ;;
    esac
    exit 0
    echo $pid_file
    
     

Comparte esta página