pingostack / pingos

Based on the NGINX/RTMP/HTTP-FLV/HTTP-TS/HLS/HLS+/DASH/H.264/H.265/AAC/MP3/Live/Record/VOD/Push/Pull/Multiple Processes/Dynamic Configuration/Configuration Variables/Console Interface/Notify
https://pingos.io
BSD 3-Clause "New" or "Revised" License
987 stars 273 forks source link

pingos exec_pull参数 执行问题 #44

Open sincez opened 3 years ago

sincez commented 3 years ago

由于想通过exec_pull 来动态拉流转rtmp,我这边前端请求hls2的流地址的时候,追加了uri参数,但是拉流一直不成功,不知道是神什么原因,前端请求的m3u8地址为:http://127.0.0.1:8080/hls2/test.m3u8?uri=openUrl/IoAs24w nginx记录的错误日志,提示应该是报错,但是看不到实际执行的命令,不知道是哪里出错了,手动使用ffmpeg命令的时候是正常的,但是放到exec_pull里面,就会执行失败,不知道设么原因,麻烦帮看下什么原因呢?我这还有个问题,http-flv的流,一直请求不成功,实在找不到什么原因,也请帮忙看下,谢谢🙏,下边是我的nginx配置文件 `#user root; master_process on; worker_processes auto;

worker_rlimit 4g;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log debug;

worker_rlimit_nofile 102400; worker_rlimit_core 2G; working_directory /tmp;

pid logs/nginx.pid;

events {

use epoll;

worker_connections  1024;
multi_listen unix:/tmp/http 80;
multi_listen unix:/tmp/rtmp 1935;

}

stream_zone buckets=1024 streams=4096;

rtmp { log_format log_bandwidth '{"app":"$app","name":"$name","bitrate":$bitrate,"args":"$args","timestamp":$ntp,"ts":"$time_local","type":"$command","remote_addr":"$remote_addr","domain":"$domain"}'; access_log logs/bandwidth.log log_bandwidth trunc=60s;

server {
    listen 1935;
    serverid 000;
    out_queue 2048;
    server_name localhost;

    application live {
        rtmp_auto_pull on;
        rtmp_auto_pull_port unix:/tmp/rtmp;

       exec_pull bash -c "ffmpeg -re  -rtsp_transport tcp -i rtsp://127.0.0.1:554/$parg_uri -vcodec libx264 -vprofile baseline -f flv rtmp://127.0.0.1:1935/live/test";

        live on;
        hls on;
        hls_path /tmp/hls;
        hls_fragment 4000ms;
        hls_max_fragment 5000ms;
        hls_playlist_length 12000ms;
        hls_type event;

        hls2 on;
        mpegts_cache_time 20s;

        hls2_fragment 1300ms;
        hls2_max_fragment 1600ms;
        hls2_playlist_length 3900ms;

        wait_key on;
        wait_video on;
        cache_time 3s;
        low_latency off;
        fix_timestamp 2s;
        #h265 codecid, default 12
        hevc_codecid  12;
    }
}

}

http { include mime.types; default_type application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_X-Forwarded-For" "$http_X-Real-IP" "$host"';

access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#reset_server_name www.test1.com www.test2.com;
#gzip  on;
server {
     listen 80;
    location /rtmp_stat {
        rtmp_stat all;
        rtmp_stat_stylesheet /stat.xsl;
    }

    location /xstat {
        rtmp_stat all;
    }

    location /sys_stat {
        sys_stat;
    }

    location /control {
        rtmp_control all;
    }

    location /live {
        flv_live 1935;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header Cache-Control no-cache;
    }

    location /ts {
        ts_live 1935 app=live;
    }

    location /hls {
        # Serve HLS fragments
         types {
             application/vnd.apple.mpegurl m3u8;
             video/mp2t ts;
         }
         root /tmp;
         add_header Cache-Control no-cache;
         add_header 'Access-Control-Allow-Origin' '*';
    }

    location /hls2 {
        hls2_live 1935 app=live;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header Cache-Control no-cache;
    }

    location / {
         chunked_transfer_encoding on;
         root html/;
    }
}

}`

im-pingo commented 3 years ago

排查一下ffmpeg的安装路径,最好在/usr/bin 和 /usr/local/bin 两个目录里都添加ffmpeg工具,有些情况下可能查找的ffmpeg目录不一样