bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.55k stars 1.46k forks source link

webRTC video artifacts during re-streaming from another mediamtx #3551

Open Pepslee opened 1 month ago

Pepslee commented 1 month ago

Which version are you using?

v1.8.3

Which operating system are you using?

Describe the issue

Description

Describe how to replicate the issue

I have two mediamtx servers:

  1. remote server on arm64 (192.168.1.2)
  2. local server on amd64 (0.0.0.0)

There is a gstreamer pipeline on the remote device with rtspclientsync which reads from the camera and publishes into mediamtx. Pipeline and mediamtx are on the same host.

Locally I have mediamtx which pulls from remote mediamtx via webrtc whep: Part of the config that describes the path

paths:
  local:
     source: "whep://192.168.1.2:8889/remote/whep"

I opened in the browser http://192.168.1.2:8889/remote And another page is http://0.0.0.0:8889/local So I try to open the stream directly from remote mediamtx and local mediamtx, which pulls the same stream from the same remote mediamtx. The picture from remote mediamtx looks great, but a picture from local mediamtx has some artifacts. (attached video and logs from both mediamtx instances). The network connection between local and remote devices is cellular, so bandwidth is unstable. local_log.txt remote_log.txt

https://github.com/user-attachments/assets/ec0ff2ad-6ea5-4cdf-9166-a41200af569c

artifact timestamps: 00:18 00:34 00:47 01:33 01:42

I tried one more approach, to pull from remote mediamtx to local mediamtx with rtsp:

paths:
  local:
     source: "rtsp://192.168.1.2:8554/remote"

reading rtsp with gstreamer With this approach, there are no artifacts, but the stream that I read directly from remote mediamtx is great, but the stream from local mediamtx is freezing and delayed.

Is there any way to fix these glitches and artifacts during mediamtx to mediamtx webrtc streaming? Thanks in advice

Did you attach the server logs?

yes

Did you attach a network dump?

no

asturl commented 1 month ago

I want to "bump" this because I have dealt with similar issues.

When I grab a (wifi) camera with some questionable packets through MediaMTX (or the older Simple Server), there are numerous artifacts in the video. Not unsurprising over an unstable connection - so I have the choice, with UDP I get the artifacts you see on your right side, and with TCP I get the connection losses from your left side. Perhaps that's a direction you can investigate.

Now the interesting part - when I pass the RTSP path of this server to a different rtsp restreamer (not MediaMTX), it somehow works much better (no connection losses, no artifacts, just some unavoidable freeze frames due to realtime video over wifi) than if either server does this individually. I wish I could get this "rtsp over tcp resilience" behaviour with just MediaMTX somehow but couldn't figure out a way how.