首页 > 编程知识 正文

docker视频播放器,nginx做文件服务器

时间:2023-05-06 19:02:42 阅读:166261 作者:3828

nginx构建基于http协议的视频点播1,下载安装nginx稳定版,http://nginx.org/en/download.html

2 )安装相关库pcre zlib openssl,首先确认有无安装。 FTP ://FTP.csx.cam.AC.uk/pub/software/programming/pcre /

http://zlib.net/zli B-1.2.8. tar.gz

33558 www.OpenSSL.org/source/OpenSSL-1.0.1 f.tar.gz

[ root @ localhost vsftpd ] # rpm-QA pcre

pcre-7.8-7.el6.i686

3、下载nginx _ mod _ h264 _ streaming-2.2.7.tar.gz

3358 h264.code-shop.com/download/nginx _ mod _ h264 _ streaming-2.2.7.tar.gz

解压nginx _ mod _ h264 _ streaming-2.2.7.tar.gz并添加flv、mp4模块。 解压缩到与nginx源相同级别的目录。

4、下载nginx-rtmp-module

3359 github.com/arut/nginx-rtmp-module

unzip nginx-rtmp-module-master

5、flv和http随nginx提供,无需下载此模块。

./configure

--sybm-path=/usr/local/sybm

- add-module=./nginx-rtmp-module-1.0.2

--with-http_ssl_module

- add-module=./nginx _ mod _ h264 _ streaming-2.2.7

--with-pcre=./pcre-8.32

--with-zlib=./zlib-1.2.8

--with-http_flv_module

--with-http _ stub _ status _ module

--with-http_mp4_module

./configure-- add-module=/usr/server/nginx _ mod _ h264 _ streaming-2.2.7-- sybm-path=/usr/locacaginx

选择需要的编译选项

Nginx的编译选项不少。 基本上是定制的位置和模块,分别如下所示。

1----sybm-path=/usr/local/sybm

从源代码编译Nginx时,它安装在/usr/local/nginx目录中,/usr/local/nginx/sybm/nginx文件为/usr/local/nginx

(作为程序员,我们习惯在--prefix上查找ybm文件。)

2----with-http_SSL_module

主要支持https访问

美妆

制造安装

5、make可能会遇到问题1

/root/nginx _ mod _ h264 _ streaming-2.2.7/src/ngx _ http _ streaming _ module.c : in function‘ngx _ ngx _ 7

/root/nginx _ mod _ h264 _ streaming-2.2.7/src/ngx _ http _ streaming _ module.c :1583360 error 3360‘

make [1] : * * * [ objs/addon/src/ngx _ http _ h264 _ streaming _ module.o ] error 1

make [1] : leaving directory `/root/nnginx-1.5.9 '

make: **

* [build] Error 2
     那么将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了
/* TODO: Win32 */
if (r->zero_in_uri)
{
     return NGX_DECLINED;
}

可能遇到问题2
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误: 变量‘stream_priority’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误: 变量‘stream_id’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误: 变量‘level_indication’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误: 变量‘profile_compatibility’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误: 变量‘profile_indication’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误: 变量‘configuration_version’被设定但未被使用 [-Werror=unused-but-set-variable]

cc1: all warnings being treated as errors

make[1]: *** [objs/addon/src/mp4_reader.o] 错误 1

解决方法:
# vim objs/Makefile (修改objs/Makefile文件, 去掉其中的"-Werror"), 然后就能够正常编译了.
6, make install


7,配置 nginx.conf  主要是server部分

server {
            listen       8999;
            server_name  192.168.1.104;
            root    /usr/local/nginx/html/flv_file/;
            limit_rate_after 5m;   
            limit_rate 512k;        
   
            index   index.html;
            charset utf-8;
    
            location ~ .flv {
                flv;
            }
    
            location ~ .mp4$ {
                mp4;
            }
    
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }
8,启动nginx,创建 /usr/local/nginx/html/flv_file/目录。
 cd /usr/local/nginx
启动  ./nginx
优雅关闭   ./nginx -s quit
快速关闭   ./nginx -s stop


nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

/usr/local/sybm/nginx  -c /usr/local/nginx/conf/nginx.conf -s reload

9,上传mp4视频文件CY.mp4

10,写个html测试。看之前的文章用jwplayer来测试,但是我这边一直报jwplayer udefined。

Loading the player ...
<video src=" http://192.168.1.104:8999/CY.mp4" controls="controls" width="50%" height="50%">

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/807718/viewspace-2150599/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/807718/viewspace-2150599/

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。