原创 车前猛跑 最后发布于2018-04-19 18:16:48 阅读数 2825

    收藏

    发布于2018-04-19 18:16:48

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

    a. 如果以前通过apt-get安装了nginx,需要卸载(sudo apt remove nginx)
    b. 去官网下载nginx http://nginx.org/en/download.html(我用的是1.12)

    c. 下载nginx-rtmp-module

    官方github地址:https://github.com/arut/nginx-rtmp-module

    git clone https://github.com/arut/nginx-rtmp-module.git

    d. 解压下载的nginx,进入nginx目录,写一个配置脚本config_nginx_1.12.sh内容如下:

    1. ./configure --prefix=/usr/local/nginx \
    2. --add-module=../nginx-rtmp-module \
    3. --with-http_flv_module \
    4. --with-http_mp4_module \

    执行:chmod +x config_nginx_1.12.sh
    ./config_nginx_1.12.sh
    会报出如下错误:

    1. ./configure: error: the HTTP rewrite module requires the PCRE library.
    2. You can either disable the module by using --without-http_rewrite_module
    3. option, or install the PCRE library into the system, or build the PCRE library
    4. statically from the source with nginx by using --with-pcre=<path> option.

    意思就是HTTP rewrite模块需要PCRE 库,要么你加个不要这个模块的选项重新配置nginx,要么就安装PCRE。当然必须选择安装PCRE。

    sudo apt install libpcre3 libpcre3-dev

    系统报告libpcre3早就装好了,其实只需要装开发库libpcre3-dev。
    重新配置,这次报告是需要OpenSSL,继续装:

    sudo apt install openssl libssl-dev

    系统报告openssl早就装好了,已经是最新版本了,想来还是跟PCRE一样,只需要装个开发库。

    继续./config_nginx_1.12.sh
    然后 make
    sudo make install

    sudo vim /usr/local/nginx/conf/nginx.conf

    在最下面添加如下内容:

    1. rtmp {
    2. server {
    3. listen 1935;
    4. chunk_size 4000;
    5. application hls {
    6. live on;
    7. hls on;
    8. hls_path /usr/local/nginx/html/hls;
    9. hls_fragment 5s;
    10. }
    11. }
    12. }

    这里的视频流目录:hls_path设置为 /usr/local/nginx/html/hls,这个目录的权限用chmod设置为775。

    cd /usr/local/nginx/sbin
    sudo ./nginx -t
    sudo ./nginx

    ubuntu   rtmp   ffmpeg(硬解码)   树莓派实现视频直播(第一步)_运维_车前猛跑-CSDN博客 - 图1 ubuntu   rtmp   ffmpeg(硬解码)   树莓派实现视频直播(第一步)_运维_车前猛跑-CSDN博客 - 图2

    发布了142 篇原创文章 · 获赞 12 · 访问量 27万+