nginx-rtmp-module. директива on_connect и hls

300 views
Skip to first unread message

kilg k

unread,
Feb 28, 2014, 12:34:47 AM2/28/14
to nginx-...@googlegroups.com
Добрый день.
Не получается задействовать директиву on_connect.
Ситуация следующая: на вход идет rtmp поток.
в application conf поток переводится в hls.
Конфиг nginx:

user  root;
worker_processes  1;

error_log  /var/log/rtmp.log debug;

events {
    worker_connections  1024;
}

rtmp_auto_push on;

rtmp {
    server {
        listen 1935;
        on_connect http://localhost/auth;

        application conf {

           live on;
           exec_static /var/www/video/wrapper.sh stream0;
           exec_kill_signal term;
        }
        application tohls {
           live on;
           hls on;
           hls_path /var/www/video;
           hls_fragment 5s;
           hls_playlist_length 20s;
        }
    }
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    server {
        listen       80;
        server_name  video-server;

        location / {
           root /var/www/video;
           }
        location /auth {
         if ($arg_id = 'icanit') {
                return 201;
                }
         return 404;
        }
        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /var/www/video;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

wrapper.sh
 cat wrapper.sh
#!/bin/bash
#while [ 1 ]
#do
on_die ()
{
    # kill all children
    pkill -KILL -P $$
}

trap 'on_die' TERM

ffmpeg -i rtmp://source/live/stream -codec copy -map 0 -f segment -vbsf h264_mp4toannexb  -flags -global_header -segment_format mpegts -segment_list stream.m3u8 -segment_time 30 -segment_list_size 0 -f flv rtmp://video-server/tohls/stream?id=icanit &

wait
#done

Проблема в том, что после директивы on_connect у ffmpeg нет доступа до потока rtmp://video-server/tohls/stream
RTMP_ReadPacket, failed to read RTMP packet header
rtmp://video-server/tohls/stream: Operation not permitted
Reply all
Reply to author
Forward
0 new messages