Ubuntu 16.04簡易安裝Nginx-rtmp-module
libnginx-mod-rtmp
是18.04上自帶的,可以通過apt-get install libnginx-mod-rtmp
進行安裝,在16.04
上如果想要安裝抹腿,直接下載libnginx-mod-rtmp_1.14.0-0+xenial1_amd64.deb
安裝的話會被告知nginx
版本過低,依賴有問題净嘀,需要16.04
自帶的nginx
版本是1.10
奏寨,rtmp需要1.14
。而一些其他文章都是需要編譯nginx
和nginx-rtmp-module
來實現(xiàn)的安裝旦棉。而我并不想上來就編譯。找到了升級nginx
的方法药薯,將nginx
升級后即可apt-get install libnginx-mod-rtmp
安裝libnginx-mod-rtmp
了绑洛。
升級nginx到1.14
依次運行如下命令:
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
來源:https://stackoverflow.com/a/44116781/2193455
安裝libnginx-mod-rtmp
tony@pc:~/Downloads$ sudo apt-get install libnginx-mod-rtmp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
binutils-arm-linux-gnueabihf cpp-5-arm-linux-gnueabihf cpp-arm-linux-gnueabihf gcc-5-arm-linux-gnueabihf-base gcc-5-cross-base libasan2-armhf-cross libatomic1-armhf-cross libc6-armhf-cross libc6-dev-armhf-cross
libgcc-5-dev-armhf-cross libgcc1-armhf-cross libgomp1-armhf-cross libstdc++6-armhf-cross libubsan0-armhf-cross linux-headers-4.15.0-33 linux-headers-4.15.0-33-generic linux-image-4.15.0-33-generic linux-libc-dev-armhf-cross
linux-modules-4.15.0-33-generic linux-modules-extra-4.15.0-33-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
libnginx-mod-rtmp
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 142 kB of archives.
After this operation, 371 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/nginx/stable/ubuntu xenial/main amd64 libnginx-mod-rtmp amd64 1.14.0-0+xenial1 [142 kB]
Fetched 142 kB in 23s (6,165 B/s)
Selecting previously unselected package libnginx-mod-rtmp.
(Reading database ... 363674 files and directories currently installed.)
Preparing to unpack .../libnginx-mod-rtmp_1.14.0-0+xenial1_amd64.deb ...
Unpacking libnginx-mod-rtmp (1.14.0-0+xenial1) ...
Setting up libnginx-mod-rtmp (1.14.0-0+xenial1) ...
Processing triggers for nginx-full (1.14.0-0+xenial1) ...
Triggering nginx reload ...
tony@pc:~/Downloads$
這樣就成功在Ubuntu 16.04上安裝了libnginx-mod-rtmp
。
測試
打開/etc/nginx/nginx.conf
添加如下配置
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
}
}
}
然后先重啟
sudo systemctl restart nginx
開啟推流端
ffmpeg -i test.mp4 -codec copy -f flv rtmp://localhost/live
開啟拉流端
ffplay "rtmp://localhost/live live=1"
其他注意事項
如果是在阿里云或者騰訊云上安裝童本,還要在安全組里打開1935
端口真屯。