日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux搭建直播步骤,linux环境(CentOS-7)搭建HLS直播测试环境

發布時間:2023/12/20 linux 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux搭建直播步骤,linux环境(CentOS-7)搭建HLS直播测试环境 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝帶rtmp的nginx

前提:需要yum update、wget、tar、gcc、pcre、pcre-devel、openssl

1.下載軟件:

mkdir nginx

cd nginx

wget http://nginx.org/download/nginx-1.17.8.tar.gz

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

2.解壓軟件:

tar -zxvf nginx-1.17.8.tar.gz

unzip master.zip

cd nginx-1.17.8

3.安裝nginx:

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master

make && make install

4.啟動nginx:

service nginx start

5.設置開機啟動(可不要)

wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx

chmod +x /etc/init.d/nginx

update-rc.d nginx defaults

配置nginx使用RTMP

vi /usr/local/nginx/conf/nginx.conf

rtmp {

server {

listen 1935;

chunk_size 4096;

application live {

live on;

record off;

}

}

}

安裝ffmpeg

1.安裝yasm:http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

2.安裝nasm2.13.0:https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz

3.yum install bzip2

4.安裝x264:https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2

./configure --enable-static --enable-shared

5.安裝SDL2: http://www.libsdl.org/release/SDL2-2.0.10.tar.gz

6.安裝FFmpeg: http://www.ffmpeg.org/releases/ffmpeg-4.1.5.tar.gz

./configure --enable-shared --enable-ffplay --enable-gpl --enable-libx264

make && make install

配置hsl

vi /usr/local/nginx/conf/nginx.conf

http.server下添加:

location /hls {

# CORS setup

add_header 'Access-Control-Allow-Origin' '*' always;

add_header 'Access-Control-Expose-Headers' 'Content-Length';

# allow CORS preflight requests

if ($request_method = 'OPTIONS') {

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Max-Age' 1728000;

add_header 'Content-Type' 'text/plain charset=UTF-8';

add_header 'Content-Length' 0;

return 204;

}

types {

application/vnd.apple.mpegurl m3u8;

video/mp2t ts;

}

root /tmp/;

add_header Cache-Control no-cache;

}

rtmp.server下添加:

application hls {

live on;

hls on;

hls_path /tmp/hls;

}

推送視頻及訪問

1.推送rtmp

ffmpeg -re -i your_source.mp4 ?-vcodec copy -f flv rtmp://localhost:1935/live/test

rtmp://192.168.0.199:1935/live/source

ffplay rtmp://localhost:1935/live/source

2.推送hsl

ffmpeg -re -i czyyjx.mp4 -vcodec libx264 -vprofile baseline -acodec aac -strict -2 -f flv rtmp://localhost:1935/live/source

ffmpeg -re -i czyyjx.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 rtmp://localhost:1935/hls/source

http://192.168.0.199/hls/source.m3u8

相關問題

1. 解決ffmpeg執行報錯“ffmpeg: error while loading shared libraries: libx264.so.138: cannot open shared object file: No such file or directory”的問題

cd ffmpeg

ldd ffmpeg

find /usr -name 'libx264.so.138' ({path})

export LD_LIBRARY_PATH={path}

2.防火墻設置:

(/etc/sysconfig/iptables)

yum install iptables-services

systemctl enable iptables

systemctl start iptables

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables -A INPUT -p tcp --dport 1935 -j ACCEPT

iptables -A INPUT -p tcp --dport 21 -j ACCEPT

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

service iptables save

service iptables restart

總結

以上是生活随笔為你收集整理的linux搭建直播步骤,linux环境(CentOS-7)搭建HLS直播测试环境的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。