一、环境搭建

音视频开发免费学习地址:

(先关注,不迷路)

1.1 C++环境

sudo apt-get update# 更新软件包
sudo apt-get install build-essential -y # 安装C++开发环境
sudo apt-get install gdb -y#安装gdb
sudo apt-get install libtool -y
sudo apt-get install pkg-config -y
sudo apt-get install automake -y
sudo apt-get install autoconf -y

1.2 golang环境

wget https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz -O ~/go1.16.5.linux-amd64.tar.gz

2.解压并重命名文件夹,方便不同版本区分

cd ~
tar -xvf go1.16.5.linux-amd64.tar.gz 
mv go go1.16.5

3.配置环境变量

tee -a $HOME/.bashrc <<'EOF'
# Go envs
export GOVERSION=go1.16.5 # Go 版本设置
export GO_INSTALL_DIR=$HOME/go1.16.5 # Go 安装目录
export GOROOT=$GO_INSTALL_DIR # GOROOT 设置
export GOPATH=~/workspace/golang # GOPATH 设置
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH # 将 Go 语言自带的和通过 go install 安装的二进制文件加入到 PATH 路径中
export GO111MODULE="on" # 开启 Go moudles 特性
export GOPROXY=https://goproxy.cn,direct # 安装 Go 模块时,代理服务器设置
EOF

4.验证配置

go version

二、编译和启动srs

git clone -b v4.0.146 https://gitee.com/winlinvip/srs.oschina.git srs.4.0.146
cd srs.4.0.146/trunk
./configure
make -j4
./objs/srs -c conf/rtc.conf

三、启动信令服务器

cd 3rdparty/signaling
make -j4
cd objs
./signaling

四、启动web服务器

cd 3rdparty/httpx-static 
make -j4
./objs/httpx-static -http 80 -https 443 -ssk server.key -ssc server.crt \
    -proxy http://127.0.0.1:1989/sig -proxy http://127.0.0.1:1985/rtc \
    -proxy http://127.0.0.1:8080/

【文章福利】小编整理了一些学习资料、教学视频和学习路线图共享在群文件,资料包括《Andoird音视频开发必备手册+音视频最新学习视频+大厂面试真题+2022最新学习路线图+项目实战源码》等等(C/C++,Linux,FFmpeg ,webRTC, rtmp, hls, rtsp, ffplay, srs),免费分享,有需要的可以点击788280672加群自取~希望对大家有帮助!

参数说明:

-http: http监听的端口

-https: https监听的端口

-domain: https域名

-root: 万维网根路径

-cache: letsencrypt缓存

lets:

-ssk: https key

-ssc: https cert

proxy: 代理服务器地址 -> srs

sdomain: ssl域名

skey: 域名的SSLkey

scert: 域名证书

生成证书:

openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.crt -days 3650

端口说明

1935: rtmp服务

1985: http api服务

8080: http-flv、hls服务

1989: 信令服务

五、rtc.conf说明

# RTMP监听端口,使用ip:port分割
# eg. 192.168.3.249:1935 10.10.10.100:1935
# 默认0.0.0:1935
listen              1935;
# 最大连接数,如果超出最大连接数,服务器将会拒绝新的连接,默认值1000
max_connections     1000;
# 是否启动守护进程,默认开启
daemon              off;
# # the log tank, console or file.
# if console, print log to console.
# if file, write log to file. requires srs_log_file if log to file.
# default: file.
# 日志输出的目标,console或者file,如果设置成file需要配置srs_log_file
srs_log_tank        console;

# HTTP配置
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}


# srs api配置
# the http api config, export for external program to manage srs.
# user can access http api of srs in browser directly, for instance, to access by:
#       curl http://192.168.1.170:1985/api/v1/reload
# which will reload srs, like cmd killall -1 srs, but the js can also invoke the http api,
# where the cli can only be used in shell/terminate.
http_api {
	# 是否启用HTTP api,默认off
    enabled         on;
    listen          1985;
}

stats {
    network         0;
}
rtc_server {
    enabled on;
    # Listen at udp://8000
    listen 8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/wiki/v4_CN_RTCWiki#config-candidate
    #candidate $CANDIDATE;
    candidate 42.192.181.115;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
}

音视频开发 2022最新学习资料、教学视频有需要的可以自行添加学习交流群或者点击资料领取