天天看點

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+