ps4/5的系统现在已经内置了直播功能,可以让玩家直接推流到twitch和youtube直播。
但是对于我们国内玩家来说,更需要的在国内的直播平台直播。请不要担心,我们可以通过一些微小操作来推流到国内的直播平台
我的设备
- 游戏机:ps5
- 电脑:Macbook air
- 路由器:刷了padavan的斐讯k2
思路
- 劫持域名流量到一台电脑上。
ps5直播的时候会把数据流发送到
.contribute.live-video.net
的1935端口,我们要把这个域名的流量劫持了,导向到电脑上。- 使用nginx-rtmp-module接收劫持的视频流并转发。
电脑上运行着nginx-rtmp-module,nginx会在1935端口把ps5的视频流接收了。我们可以访问nginx,获得它接受的流。
- 使用obs推流。
在obs里面填入访问nginx的地址,就可以获得视频流,然后正常地推流到b站。
路由器劫持域名流量
ps: 如果使用mac访问padavan路由器管理页面非常慢,这是因为mac系统的问题,去更新最新的padavan路由器固件,更新了就好了。


# twitch直播劫持 address=/contribute.live-video.net/192.168.124.100
在最下面这里可以给电脑指定ip,这样能防止重连导致分配的ip变化,还得来改这个劫持转发的地址。
安装Nginx-rtmp
因为我们安装的nginx是用作接受流的,所以需要安装nginx-rtmp-module。
这个第三方brew nginx的详情请看:https://github.com/denji/homebrew-nginx
先拉一下github上第三方nginx的brew包
brew tap denji/nginx
安装带有nginx-rtmp-module的nginx
brew install nginx-full --with-rtmp-module
查看安装好的nginx
brew info nginx-full
安装好以后我们需要进行配置。
首先我们要先找到nginx-rtmp-module的
stat.xsl
文件的位置brew list | grep nginx

注意,名字叫
rtmp-nginx-module
,不是 nginx-rtmp-module
brew info rtmp-nginx-module

来到这个目录,找到
stat.xsl
文件
我们要复制到nginx的web根目录下
查看nginx的web根目录在哪
brew info nginx-full


接下来修改nginx的配置文件。
查看nginx的配置文件在哪:
brew info nginx-full

这里就是nginx配置文件的位置,打开这个文件进行编辑。
在 http 块前加上 rtmp 块
rtmp { server { listen 1935; application app { live on; } } }
在 http 的 server 块中加入 rtmp 状态页面配置,修改
location /
部分location / { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root html; }
root html
是因为html文件夹链接到了 www
文件夹这是完整的配置文件
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } rtmp { server { listen 1935; application app { live on; } } } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root html; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} include servers/*; }
使用
brew info nginx-full
可以查看启动、重新载入配置文件的命令
启动nginx:
nginx
重新载入配置
nginx -s reload
注意要先启动了nginx,才能使用
nginx -s reload
这些命令。
显示的是这个画面就说明nginx已经安装并配置好了。
配置ps5
因为在向twitch推流的时候,会首先访问twitch进行通信,成功了以后再进行推流,所以我们需要给ps5翻墙。
翻墙的形式没有限制,只要能让ps5能访问twitch就可以了。注意,使用加速器可以看twitch,但是无法进行推流前的访问,所以得给ps5翻墙。
我使用的是通过电脑上的v2ray软件给ps5翻墙,请注意在软件上开启 ”允许局域网的连接“。
1.给ps5翻墙
在ps5连接WiFi的时候,代理服务器那里选择开启,ip填同一个局域网的电脑,端口填软件的端口,这样就可以让ps5翻墙了。
2.连接twitch账号
打开一个游戏,按一下手柄左上方的share键,选择播放游戏,会让你连接twitch账号,按照引导连接好账号。
再次进行播放游戏,这时候就可以进行推流了。
打开
localhost:8080
,如果成功劫持推流,就会是这样的:
打码这里是我的twitch推流密钥,请注意不要泄露这个密钥出去!
3.配置obs
打开obs软件



rtmp://localhost:1935/app/live_一串数字_一串字符
把
live_一串数字_一串字符
替换成在 localhost:8080
看到的那串推流密钥
这样就表示obs成功拉到了我们劫持的那个流了,接着我们就可以推流到b站。
刚开始我把地址填进obs发现是黑的,以为流有问题,但是其实是画面没有展开来

先点一下下面的ps5这一项,然后把上面红色这个点拉大来,可能是bug,没有自动展开画面。
去b站直播中心,点击开启直播获得串流密钥,填进这里



这是我的推流设置
先在b站开启直播
然后点击开始推流


这样就是成功推流了
后记
其实开播了也没什么人看,主要是给朋友图一乐。
而且折腾后,最后成功了比打游戏有意思。
其中遇到个坑,就是开始我是使用docker封装好的nginx-rtmp,但是大部分时候接收不到ps5的推流,即使接收到了,一段时间后又会断开。
因为docker在mac上是以虚拟机形式运行了一个Linux,我怀疑是这个系统上的问题,然后就选择安装nginx的方式。使用安装的nginx确实没有这个问题了。
这个办法比较简单地实现了推流到b站。我看到另外用Linux系统,可以把直播弹幕也转发到ps5上,这样打游戏的时候也能看到b站的弹幕。
特别想要直播弹幕的可以尝试一下:https://github.com/Tilerphy/ps4broadcast