流媒體服務(wù)器是一種專門用于傳輸實(shí)時(shí)數(shù)據(jù)流的服務(wù)器軟件,廣泛用于視頻直播、視頻會(huì)議、音頻播放等應(yīng)用場(chǎng)景。在嵌入式開(kāi)發(fā)領(lǐng)域,將流媒體服務(wù)器部署到開(kāi)發(fā)板上可以實(shí)現(xiàn)諸如視頻監(jiān)控、實(shí)時(shí)數(shù)據(jù)傳輸等功能。本文將介紹如何利用nginx和其rtmp流媒體模塊,在ELF 1開(kāi)發(fā)板上搭建一個(gè)高效穩(wěn)定的流媒體服務(wù)器。
1、下載源碼
http://nginx.org/download/
https://github.com/arut/nginx-rtmp-module.git
elf@ubuntu:~/work$ tar -zxvf nginx-1.20.0.tar.gz
elf@ubuntu:~/work$ unzip nginx-rtmp-module-master.zip
elf@ubuntu:~/work$ cd nginx-1.20.0/
elf@ubuntu:~/work/nginx-1.20.0$ . /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
elf@ubuntu:~/work/nginx-1.20.0$ vi auto/cc/name
elf@ubuntu:~/work/nginx-1.20.0$ vi auto/types/sizeof
elf@ubuntu:~/work/nginx-1.20.0$ ./configure --prefix=/home/elf/work/nginx-1.20.0/install --with-http_ssl_module --with-http_mp4_module --with-http_v2_module --with-http_v2_module --without-http_upstream_zone_module --add-module=/home/elf/work/nginx-rtmp-module-master
elf@ubuntu:~/work/nginx-1.20.0$ vi objs/ngx_auto_config.h
#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM 1
#endif
elf@ubuntu:~/work/nginx-1.20.0$ make
elf@ubuntu:~/work/nginx-1.20.0$ make install
elf@ubuntu:~/work/nginx-1.20.0$ ls install/
conf html logs sbin
root@ELF1:~# cp /run/media/sda1/sbin/nginx .
root@ELF1:~# mkdir /etc/nginx
root@ELF1:~# cp -r /run/media/sda1/conf/ /etc/nginx/
root@ELF1:~# cp -r /run/media/sda1/html/ /etc/nginx/
root@ELF1:~# cp -r /run/media/sda1/logs/ /etc/nginx/
root@ELF1:~# ls /etc/nginx/
conf html logs
(1)查看版本信息和幫助信息
root@ELF1:~# ./nginx -V
root@ELF1:~# ./nginx -h
(2)啟動(dòng)nginx
root@ELF1:~# ./nginx -p /etc/nginx/
root@ELF1:~# ps -aux