在5G流行的今天流媒体,成为不少开发人员的必备功课,所以自己搭建流媒体服务器也是必须的,今天就以Mac环境为模板,从零开始搭建一个本地流媒体服务器。 首先需要安装 1.安装Homebrew 打开终端, 查看是否已经安装了Homebrew, 直接终端输入命令
man brew
2.如果Mac已经安装了, 会显示一些命令的帮助信息. 此时 输入Q退出即可, 直接进入第二步 如果尚未安装,执行
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
这里有时会提示我们只需要等待便可
Downloading Command Line Tools (macOS Mojave version 10.14) for Xcode
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Failed during: /usr/local/bin/brew update --force
3.需要brew update一下
Error: homebrew/nginx was deprecated. This tap is now empty as all its formulae were migrated.
MacBook-Pro:~ jiayuan$ brew tap homebrew/nginx Error: homebrew/nginx was deprecated. This tap is now empty as all its formulae were migrated.
4.安装成功
HEAD is now at bcc5f042b Merge pull request #6143 from letmaik/letmaik/HOMEBREW_CURL_RETRIES Already up-to-date. ==> Installation successful!
5.安装之后先更新一下 brew update
6.这里会提示一个错误
To restore the stashed changes to /usr/local/Homebrew run: 'cd /usr/local/Homebrew && git stash pop' Usage: brew install [options] formula
Install formula.
formula is usually the name of the formula to install, but it can be specified in several different ways.
Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will be run for the installed formulae or, every 30 days, for all formulae.
7.需要先安装nginx
brew install nginx
会提示更新xcode如果不需要刻意删除,然后会提示
8.这里会提示xcode更新的问题没有安装的会提示安装 ==> Installing nginx-full from denji/nginx Error: Your Xcode (10.1) is too outdated. Please update to Xcode 10.2.1 (or delete it). Xcode can be updated from the App Store.
如果版本过低的话需要先将系统更新至10.2以上,在更新xcode,没有安装也没事主要是使用里面的xcode command line tool,但是版本需要更新至10.2以上
brew unlink nginx 这里是链接一下nginx
更新之后再次安装rtmp
brew install nginx-full --with-rtmp-module
会提示这个错误,需要多尝试几下
curl: (7) Failed to connect to github.com port 443: Operation timed out
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "rtmp-nginx-module--patch"
Download failed: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/compare/v1.1.7.10..504b9ee.diff
如果安装成功会出现下面这段提示
To have launchd start denji/nginx/nginx-full now and restart at login: brew services start denji/nginx/nginx-full Or, if you don't want/need a background service you can just run: nginx
然后配置一下nginx端口rtmp服务在配置文件中
# 文件路径:/usr/local/etc/nginx/nginx.conf
vim /usr/local/etc/nginx/nginx.conf
主要是添加以下内容
#配置 rtmp server
rtmp{
server{
#指定服务器端口
listen 1935;
chunk_size 4000;
#指定流应用
application live
{
live on;
record off;
allow play all;
}
}
}
然后启动nginx,如果已经启动过则是
nginx -s -reload
安装FFmpeg
brew install ffmpeg
最后下载一个vlc进行屏幕录制,然后使用第三方播放器就行测试(我这里使用的是腾讯的)
评论(0)