notedit / media-server-go-demo

webrtc media server go demo
MIT License
212 stars 64 forks source link

rtmp-to-webrtc demo run fail #19

Closed mightZhong closed 4 years ago

mightZhong commented 4 years ago

Hi, I try to run rtmp-to-webrtc demo, but there is no video show on my web. The modification I make as follow:

  1. index.html => socket = new WebSocket('ws://x.x.x.x:8000/channel');
  2. rtmp-to-webrtc/server.go => var endpoint = mediaserver.NewEndpoint("x.x.x.x") note: x.x.x.x is my server public IP Then I build rtmp-to-webrtc and deploy it to the server above mentioned, of course, I copy index.html to server too.

My test steps as follow:

  1. push stream to rtmp://x.x.x.x:1935 with OBS tool
  2. Input http://x.x.x.x:8000 in my chrome, it just show "MediaServer Demo", but no video

These are logs output by rtmp-to-webrtc: [0x7fa8203dc740][1578484123.799][LOG]>RTPTransport::Init() [0x7fa8203dc740][1578484123.799][LOG]-RTPTransport::Init() | Got ports [55746,55747] [0x7fa8203dc740][1578484123.799][LOG]<RTPTransport::Init() [0x7fa8203dc740][1578484123.801][LOG]>RTPTransport::Init() [0x7fa8203dc740][1578484123.801][LOG]-RTPTransport::Init() | Got ports [47867,47868] [0x7fa8203dc740][1578484123.801][LOG]<RTPTransport::Init() helloworld [GIN] 2020/01/08 - 19:48:51 | 200 | 192.581µs | 42.120.72.102 | GET / OnDTLSStateChange 3 error: websocket: close 1001 (going away) [GIN] 2020/01/08 - 19:48:52 | 200 | 4m40.874353921s | 42.120.72.102 | GET /channel [GIN] 2020/01/08 - 19:48:55 | 404 | 559ns | 42.120.72.102 | GET /favicon.ico [0x7fa81b0c8700][1578484135.210][LOG]-RTPBundleTransport::AddICETransport [5fb90badb37c5821:9nnL] [0x7fa81b0c8700][1578484135.210][LOG]-RemoteRateEstimator adding stream [ssrc:0] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSConnection::SetSRTPProtectionProfiles() [profiles:''] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSICETransport::SetLocalSTUNCredentials() | [frag:5fb90badb37c5821,pwd:b6d95526a41a9504680b4e7c8b763a1b1d49d4955c848621] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSICETransport::SetRemoteSTUNCredentials() | [frag:9nnL,pwd:wHfc1eTFD9IGjJrC2L0cIuwF] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSICETransport::SetRemoteCryptoDTLS | [setup:actpass,hash:sha-256,fingerprint:5E:D3:A3:2A:DC:06:49:E8:DE:F2:2C:C9:B8:18:72:14:3C:D0:E1:F1:05:3B:E5:CC:C8:07:AD:80:50:82:13:7D] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSConnection::SetRemoteSetup() | [remote:2] [0x7fa81b0c8700][1578484135.211][LOG]>DTLSConnection::Init() [0x7fa81b0c8700][1578484135.211][LOG]<DTLSConnection::Init() [0x7fa81b0c8700][1578484135.211][LOG]-DTLSICETransport::AddOutgoingSourceGroup() [group:0x7fa8044ab4c0,ssrc:1000000007,fec:0,rtx:0] [0x7fa81b0c8700][1578484135.211][LOG]-DTLSICETransport::AddOutgoingSourceGroup() [group:0x7fa8043e7cc0,ssrc:1000000008,fec:0,rtx:0] [0x7fa8198c5700][1578484135.325][LOG]-DTLSConnection::onSSLInfo() | DTLS handshake done [0x7fa8198c5700][1578484135.325][LOG]-DTLSICETransport::onDTLSSetup() [suite:1] [0x7fa8198c5700][1578484135.325][LOG]-DTLSICETransport::SetLocalCryptoSDES() | [suite:AES_CM_128_HMAC_SHA1_80] [0x7fa8198c5700][1578484135.325][LOG]-SRTPSession::AddStream() | [ssrc:1000000007,OK] [0x7fa8198c5700][1578484135.325][LOG]-SRTPSession::AddStream() | [ssrc:1000000008,OK] [0x7fa8198c5700][1578484135.325][LOG]-DTLSICETransport::SetRemoteCryptoSDES() | [suite:AES_CM_128_HMAC_SHA1_80] OnDTLSStateChange 2

I have no idea what is wrong , any suggestions would be greatly appreciated!

notedit commented 4 years ago

did not see the gstreamer log

mightZhong commented 4 years ago

Yes, there is no gstreamer log, I add some debug log and find:

  1. gstreamer has been created with parameter "appsrc do-timestamp=true is-live=true name=appsrc ! h264parse ! rtph264pay timestamp-offset=0 config-interval=-1 pt=97 ! udpsink host=127.0.0.1 port=54322", audio gstreamer has been created too.
  2. data has been pushed to the element when I test with OBS tool But there no gstreamer log and no data send to port 54322 which I checked with tcpdump
notedit commented 4 years ago

It works fine here.

here is the rtmp push command

ffmpeg -f lavfi -re -i color=black:s=640x480:r=15 -filter:v "drawtext=text='%{localtime\:%T}':fontcolor=white:fontsize=80:x=20:y=20" \
-vcodec libx264 -tune zerolatency -preset ultrafast  \
-g 15 -keyint_min 15 -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 15 -f flv "rtmp://localhost/live/live"
hexray-newbee commented 4 years ago

It works fine here.

here is the rtmp push command

ffmpeg -f lavfi -re -i color=black:s=640x480:r=15 -filter:v "drawtext=text='%{localtime\:%T}':fontcolor=white:fontsize=80:x=20:y=20" \
-vcodec libx264 -tune zerolatency -preset ultrafast  \
-g 15 -keyint_min 15 -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 15 -f flv "rtmp://localhost/live/live"

gst-launch-1.0 videotestsrc is-live=true pattern=black ! video/x-raw, width=640, height=480, framerate=15/1, format=I420 ! clockoverlay time-format="%T" ! x264enc tune=zerolatency speed-preset=ultrafast option-string="keyint=15:min-keyint=15:level=3.0" ! video/x-h264, profile=baseline ! flvmux streamable=true ! rtmpsink location="rtmp://localhost/live/live live=1"

mightZhong commented 4 years ago

hi @notedit, I test on my Mac and Linux on Mac, demo can run and I push rtmp stream with OBS tool, but the video received on web is not fluent on Live, it raise error panic: create pipeline error when I push stream

notedit commented 4 years ago

you should check your gstreamer elements if you have that error.

It is just a demo, you should polish it if you want to use it in production.

mightZhong commented 4 years ago

ok, thanks for your response