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:[email protected]/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:[email protected]/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命令错误或者是取流的地址有问题
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:[email protected]/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:[email protected]/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命令错误或者是取流的地址有问题
解决方案 »
- Tomcat启动报错!如何解决?
- 会 hibernate search 的进来看下 紧急
- struts2 链接进入到下一个页面怎么设置<s:token>
- hibernate入门问题,这个使用hibernate写入oracle数据库的例子错在哪儿?
- 用Ajax html css 设计留言板中的问题 急急!!!
- 安装的java SE的sdk,能用来开发servlet吗
- 请教2个socket的问题
- 为什么weblogic7在2K下老死机?(快救我啊)
- JBuilder8的问题
- Maven Build报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plu
- spring的包扫描的base-package配置com.test和com.test.*的区别
- 严重: Servlet.service() for servlet [jsp] in context with path [/strutstry]
这样的话,推流位置要改成rtmp://192.168.0.186:1935/live/xxxx
播放器再到http://192.168.0.186:8080/hls/xxxx.m3u8去拉流