yan_tracy 2017-10-21 14:25 采纳率: 28.6%
浏览 7857
已结题

Nginx+FFMpeng+rtmp推流HLS,rtmp正常播放,HLS不能播放

FFMpeng推rtsp流,想rtmp和HLS协议播放,rtmp能播放的出来(地址:rtmp://192.168.0.186:1935/hls/test123)
HLS不能播放(地址:http://192.168.0.186:8080/hls/test123.m3u8)

FFmpeng推流代码:

 public static void main(String[] args) {
        FFmpegManager manager = new FFmpegManagerImpl();
        Map map = new HashMap();
        map.put("appName", "test123");
        map.put("input", "rtsp://admin:admin@192.168.0.172/cam/realmonitor?channel=1&subtype=0");
        map.put("output", "rtmp://192.168.0.186:1935/hls/");
        map.put("codec", "h264");
        map.put("fmt", "flv");
        map.put("rs", "640x360");
        map.put("twoPart", "1");
        // 执行任务,id就是appName,如果执行失败返回为null
        String id = manager.start(map);
        System.out.println(id);
    }

FFmpemg命令为:

 ffmpeg -i rtsp://admin:admin@192.168.0.172/cam/realmonitor?channel=1&subtype=0 -f flv -s 640x360 -an rtmp://192.168.0.186:1935/hls/test123

Nginx.conf配置

 worker_processes  1;

#error_log  logs/error.log debug;

events {
    worker_connections  1024;
}
#切换自动推送(多 worker 直播流)模式。默认为 off
#rtmp_auto_push on;
#当 worker 被干掉时设置自动推送连接超时时间。默认为 100 毫秒
#rtmp_auto_push_reconnect 1s;
rtmp {
    server {
        listen 1935;

        #直播流设置
        application live {
            live on;

        live_auth off;  #鉴权开关
        live_auth_secret nodemedia2017privatekey; #鉴权KEY

        transcode on;           #转码开关
        transcode_appname hls;  #转码后的 app name
        transcode_ar 44100;     #转码后的采样率
        transcode_ab 128000;    #转码后的比特率
        transcode_ac 1;         #转码后的声道数
        }

        #hls切片
        application hls {
            live on;
            hls on;  
            hls_path temp/hls;  
            hls_fragment 8s;  
        }
        # rtmp日志设置
        access_log logs/rtmp_access.log ;
    }
}

http {
    server {
        listen 8080;

        location / {
            root www;
        }

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root www;
        }

        location /hls {  
            server hls fragments  
            types{  
                application/vnd.apple.mpegurl m3u8;  
                video/mp2t ts;  
            }  
            alias temp/hls;  
            expires -1;   

        }  

    }
}

请问我是哪里出问题了,是Nginx.conf配置错了还是FFmpeng命令错误?

  • 写回答

1条回答 默认 最新

  • csulizhang 2017-10-23 09:25
    关注

    你推送的是RTMP数据流,http怎么看呢,一条指令,同时收看HTTP和rtmp是不行的,你得分别推,推http流的时候要换成http的协议头,这样才能收看

    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的