一聚教程网:一个值得你收藏的教程网站

热门教程

nginx添加flv与mp4流媒体播放支持

时间:2022-06-30 18:39:53 编辑:袖梨 来源:一聚教程网

默认nginx是不支持流媒体拖放等功能的,flv内置了这个支持,只需要加上–with-http_flv_module就可以了,flv视频需要加上关键帧,用yadmi处理一下就可以了yamdi -i in.flv out.flv

已经安装nginx时,先查看nginx编译环境
/usr/local/nginx/sbin/nginx -V
看看有没有–with-http_flv_module 没有的话就加上这句
复制已有的环境,后面加上–add-module=/root/chenwei/movie/nginx_mod_h264_streaming-2.2.7
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –with-http_flv_module –add-module=/root/movie/nginx_mod_h264_streaming-2.2.7

make

ngx_http_streaming_module.c:158:8: 错误:‘ngx_http_request_t’没有名为‘zero_in_uri’的成员

找到ngx_http_streaming_module.c 158行
注释掉
if (r->zero_in_uri) { return NGX_DECLINED; } 这一段

../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”), 然后就能够正常编译了.
移动objs/nginx到nginx安装目录(/usr/local/nginx/sbin/nginx)

在网站配置文件中添加
location ~ .flv {
flv;
}
location ~ .mp4 {
mp4;
}

重启nginx
nginx -t
nginx -s reload

热门栏目