owncast是一个单用户的直播工具,带有聊天功能。
程序转码需要用到ffmpeg,建议在一台性能稍好的VPS上安装,安装基本工具:
apt -y update apt -y install ffmpeg unzip nginx python-certbot-nginx supervisor systemctl start supervisor nginx systemctl enable supervisor nginx
下载解压二进制文件:
mkdir -p /opt/owncast && cd /opt/owncast wget https://github.com/owncast/owncast/releases/download/v0.0.2/owncast-linux-0.0.2.zip unzip owncast-linux-0.0.2.zip
新建配置文件:
nano config.yaml
写入如下配置:
ffmpegPath: /usr/bin/ffmpeg webServerPort: 8080 instanceDetails: name: imlala title: MapleStory Solo Lotus summary: "Welcome" extraUserInfoFileName: "/static/content.md" logo: small: /img/logo128.png large: /img/logo256.png tags: - game - music - tech socialHandles: - platform: github url: http://github.com/owncast/owncast - platform: mastodon url: http://mastodon.something/owncast videoSettings: chunkLengthInSeconds: 5 streamingKey: password offlineContent: static/offline.m4v streamQualities: - low: videoBitrate: 400 scaledWidth: 600 audioPassthrough: true encoderPreset: veryfast - medium: videoBitrate: 800 encoderPreset: fast - high: videoBitrate: 2000 encoderPreset: faster
如果你只想开箱即用的话,修改streamingKey后面的值即可,这是你的直播密码。
其他的配置可参考如下地址的说明:
https://owncast.online/docs/configuration/
接下来新建一个supervisor配置文件用于守护owncast的进程:
nano /etc/supervisor/conf.d/owncast.conf
写入如下配置:
[program:owncast] priority=1 directory=/opt/owncast command=/opt/owncast/owncast autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/log/supervisor/owncast.log
更新supervisor配置即可启动owncast:
supervisorctl update
接下来新建nginx站点配置文件用于反向代理:
nano /etc/nginx/conf.d/owncast.conf
写入如下配置:
server { listen 80; server_name owncast.imlala.best; location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; } }
使用certbot签一个ssl证书:
certbot --nginx --agree-tos --no-eff-email --email example@qq.com
推流地址:
rtmp://owncast.imlala.best/live
OBS推流设置:
流名称就是你在config.yaml内设置的streamingKey密码。
测试一下:
泪目
大佬,服务器应该开发哪个端口给OBS推流,实在找不到,我打开了所有端口才能正常推流,但这样不安全,望给予指导,谢谢
8080和1935。
https://************/hls/stream.m3u8?cachebust=1603335465 404 (Not Found)
大佬这个是怎么回事?推流成功了,查看了owncast.log如下,
time=”2020-10-22T02:45:48Z” level=info msg=”Owncast v0.0.2-linux (ef3796a033b32a312ebf5b334851cbf9959e7ecb)”
time=”2020-10-22T02:45:48Z” level=info msg=”Web server running on port: 8080″
time=”2020-10-22T02:45:48Z” level=info msg=”RTMP server is listening for incoming stream on port: 1935″
time=”2020-10-22T02:52:05Z” level=info msg=”Owncast v0.0.2-linux (ef3796a033b32a312ebf5b334851cbf9959e7ecb)”
time=”2020-10-22T02:52:05Z” level=info msg=”Web server running on port: 8080″
time=”2020-10-22T02:52:05Z” level=info msg=”RTMP server is listening for incoming stream on port: 1935″
time=”2020-10-22T02:55:49Z” level=info msg=”Incoming RTMP connected.”
这个log看不出来是什么问题,猜测你的ffmpeg路径可能没配置好?