nginx + ffmpeg rtsp 转 rtmp

全部下载地址

https://download.csdn.net/download/androidwubo/12610387


1、下载nginx


    https://github.com/bzy880114/nginx-rtmp-win32-master

 

2、下载ffmpeg


    http://ffmpeg.org/download.html

 

3、开启nginx  


    cd nginx  打开终端  输入 start nginx.exe


    
4、调用如下命令  rtsp 转  rtmp流  必须开启nginx后再转流

 

海康摄像头rtsp地址rtsp://账号:密码@ip:port/Streaming/Channels/402?transportmode=unicast

402:4代表通道 2代表子码流 1是主码流


    ffmpeg -re  -rtsp_transport tcp -i "rtsp://账号:密码@ip:port/Streaming/Channels/402?transportmode=unicast" -f flv -r 25 -s 1960x1280 -an rtmp://localhost:1935/live/room

 

5、rtsp 转hls

 

ffmpeg -rtsp_transport tcp -i "rtsp地址rtsp://账号:密码@ip:port/Streaming/Channels/402?transportmode=unicast" -fflags flush_packets -max_delay 1 -an -flags -global_header -hls_time 1 -hls_list_size 3 -hls_wrap 3 -vcodec copy -s 216x384 -b 1024k -y D:/nginx-rtmp-win32-master/html/hls/test.m3u8 
    
    
如果需要转hls的话nginx目录下的conf 下的nginx.conf

worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;

        application live {
            live on;
        }
		
        application hls {
            live on;
            hls on;  
            hls_path html/hls;  
            hls_fragment 18s;  
        }
    }
}

http {
    server {
        listen   8083;
		
        location / {
            root html;
			index  index.html index.htm;
        }
		
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html;
        }
		
        location /hls {  
            #server hls fragments  
            types{  
                application/vnd.apple.mpegurl m3u8;  
                video/mp2t ts;  
            }  
           # 下面这个是表示转流后的m3u8文件没有缓存,保证加载的实时的
           add_header Cache-Control no-cache;
        }  

    }
}

 

你可能感兴趣的:(h5+)