当前位置: 首页 > 工具软件 > web-flash > 使用案例 >

web前端不使用flash视频流播放

欧阳成弘
2023-12-01

原因:falsh2020年年底不进行更新了,并且主流浏览器也不支持 项目需要
结果:找了一圈资料 感谢711969608群主对http-flv的开源,也谢谢群里面其他的快速回答我这个小白的问题。同时还基础解决了ffmpeg推流和关流的控制

自我小结
http-flv其实就是在nginx-rtmp的基础上,转成了http协议
1.nginx-http-flv安装
wget http://nginx.org/download/nginx-1.12.2.tar.gz
https://github.com/winshining/nginx-http-flv-module http-flv模块地址
2.安装依赖
yum -y install pcre-devel openssl openssl-devel
3.解压编译安装
./configure --prefix=/usr/loacl/nginx --add-module=/root/module/nginx-http-flv-module-master
make
make install
4.修改nginx配置 这个配置可以用 但是有多余的

events {
    worker_connections  1024;
}

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp{
	out_queue 4096;
	out_cork 8;
	max_streams 128;
	timeout 15s;
	drop_idle_publisher 15s;
	log_interval 5s;
	log_size 1m;
	server{
	 listen 1935;
​	 application rtmplive {``
		live on;
		max_connections 1024;
	}
}```
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8080;
	server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
	location /live{
		flv_live on;
		chunked_transfer_encoding  on;
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Access-Control-Allow-Credentials' 'true';
	}
	location /hls{
		types {
		application/vnd.apple.mpegurl m3u8;
		video/mp2t ts;
		 }
		 root /usr/local/nginx/html/hls;
		 add_header 'Cache-Control' 'no-cache';
	}
	 location /dash {
            root /usr/local/nginx/html/dash;
            add_header 'Cache-Control' 'no-cache';
        }

location /stat {
#configuration of push & pull status
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx/nginx-http-flv-module;
}

location /control {
rtmp_control all; #configuration of control module of rtmp
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

}`
}

**5.ffmepg安装**
yum install yasm -y
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=/usr/local/ffmpeg
make
make install


**6.推流尝试**
推流命令:ffmpeg -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov -vcodec copy -s 704x576  -acodec aac -an -f flv rtmp://IP:1935/rtmplive/test

播放地址:
http://IP:8080/live?app=rtmplive&stream=test     
**live 对应flv_live on;的配置    rtmplive 对应rtmp的配置   跟在app后面   test自定义 在stream后面
如果rtmp对应端口修改了 路径需要添加prot=XX  最后路径为
http://IP:8080/live?port=1945&app=rtmplive&stream=test
**

**7.vlc播放器检验** 
 rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov  这个是网上找的一个可用流




资料参考:
https://blog.csdn.net/caowenjing123/article/details/94623466
https://blog.csdn.net/winshining/article/details/93606585  这个文章作者一定要关注  很多相关文章  

 类似资料: