Difficulties to playback WebRTC published media using RTMP with FFPLAY on MacOS
neilyoung opened this issue · comments
Long title, sorry, but it says it all:
- Having an SRS instance running locally on my Mac
- Running WHIP publishing
http://localhost:8080/players/whip.html
with stream URLhttp://localhost:1985/rtc/v1/whip/?app=live&stream=livestream
- Having a console aside, running
ffplay rtmp://192.168.188.53/live/livestream
I can see the RTMP doing some startup in the SRS console:
[2024-03-16 13:13:32.553][INFO][34555][1603cx43] RTMP client ip=192.168.188.53:63409, fd=13
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] complex handshake success
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] connect app, tcUrl=rtmp://192.168.188.53:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.188.53, port=1935, app=live, args=null
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] ignore AMF0/AMF3 command message.
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] ignore AMF0/AMF3 command message.
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] client identified, type=rtmp-play, vhost=192.168.188.53, app=live, stream=livestream, param=, duration=-1ms
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] connected stream, tcUrl=rtmp://192.168.188.53:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=livestream, param=, args=null
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] source url=/live/livestream, ip=192.168.188.53, cache=1/2500, is_edge=0, source_id=/
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] create consumer, active=0, queue_size=30000ms, jitter=1
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] set fd=13, SO_SNDBUF=146988=>87500, buffer=350ms
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] start play smi=0ms, mw_sleep=350, mw_msgs=8, realtime=0, tcp_nodelay=0
[2024-03-16 13:13:32.554][INFO][34555][1603cx43] -> PLA time=0, msgs=0, okbps=0,0,0, ikbps=0,0,0, mw=350/8
[2024-03-16 13:13:34.923][INFO][34555][f93855z5] Hybrid cpu=0.00%,0MB, cid=1,1, timer=62,10,48, clock=0,36,11,1,0,0,0,0,0, objs=(pkt:113,raw:60,fua:52,msg:113,oth:1,buf:113)
[2024-03-16 13:13:34.923][INFO][34555][f93855z5] RTC: Server conns=1, rpkts=(115,rtp:113,stun:1,rtcp:1), spkts=(14,rtp:0,stun:1,rtcp:27), rtcp=(pli:0,twcc:9,rr:1), snk=(96,a:48,v:48,h:0), fid=(id:0,fid:115,ffid:0,addr:1,faddr:115)
[2024-03-16 13:13:35.624][INFO][34555][89981lov] Process: cpu=0.00%,0MB, threads=2
[2024-03-16 13:13:37.121][INFO][34555][00636992] <- RTC RECV #12, udp 1169, pps 226/116, schedule 1169
[2024-03-16 13:13:39.924][INFO][34555][f93855z5] Hybrid cpu=0.00%,0MB, cid=2,2, timer=61,10,48, clock=0,38,10,1,0,0,0,0,0, objs=(pkt:106,raw:62,fua:43,msg:107,oth:0,buf:106)
[2024-03-16 13:13:39.924][INFO][34555][f93855z5] RTC: Server conns=1, rpkts=(108,rtp:106,stun:1,rtcp:1), spkts=(14,rtp:0,stun:1,rtcp:27), rtcp=(pli:0,twcc:9,rr:1), snk=(96,a:48,v:48,h:0), fid=(id:0,fid:108,ffid:0,addr:1,faddr:108)
[2024-03-16 13:13:40.631][INFO][34555][89981lov] Process: cpu=0.00%,0MB, threads=2
[2024-03-16 13:13:44.924][INFO][34555][f93855z5] Hybrid cpu=0.00%,0MB, cid=2,2, timer=61,10,48, clock=0,38,10,1,0,0,0,0,0, objs=(pkt:106,raw:62,fua:43,msg:107,oth:0,buf:106)
[2024-03-16 13:13:44.925][INFO][34555][f93855z5] RTC: Server conns=1, rpkts=(108,rtp:106,stun:1,rtcp:1), spkts=(14,rtp:0,stun:1,rtcp:27), rtcp=(pli:0,twcc:9,rr:1), snk=(96,a:48,v:48,h:0), fid=(id:0,fid:108,ffid:0,addr:1,faddr:108)
[2024-03-16 13:13:45.634][INFO][34555][89981lov] Process: cpu=0.00%,0MB, threads=2
But the FFPLAY console doesn't open up the video window, it just shows:
56. 6.100
$ ffplay rtmp://192.168.188.53/live/livestream
ffplay version 5.1.4 Copyright (c) 2003-2023 the FFmpeg developers
built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
configuration: --prefix='/opt/homebrew/Cellar/ffmpeg@5/5.1.4_4' --datadir='/opt/homebrew/Cellar/ffmpeg@5/5.1.4_4/share/ffmpeg' --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
Shouldn't that work?
PS: Also not working with localhost
as RTMP host
Ok, I found that I had rtc_to_rtmp off;
in my conf. Works now. But 5 sec latency is far beyond everything acceptable for being considered as working playback solution. This is more or less not working, even if it "works" seemingly.
I'm looking for a real-time way to get the media out of SRS server-side in order to provide an RTSP feed (e.g. by using MediaMTX). I have experiences with this stuff, having done WebRTC to RTSP conversion with Kurento Media Server and MediaSoup. All of these transitions have been done with SUB SECOND latency using FFMPEG and SDP directly hooking up to a TCP UDP port carrying RTP. Nothing like this possible with SRS?
EDIT: And with sub second latency I mean the latency between camera and RTSP output...