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命令错误?