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
10.74k stars 1.4k forks source link

GStreamer RTSP Pipeline doesn't work on MediaMTX 1.8 #3284

Closed lqbrqt closed 2 months ago

lqbrqt commented 2 months ago

Which version are you using?

v1.8.0

Which operating system are you using?

Describe the issue

Description

When running MediaMTX v1.5.1 using the same config, GStreamer pipeline starts on event runOnReady. When using MediaMTX v1.8.0 it fails with

ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not read from resource.
Additional debug info:
../gst/rtsp-sink/gstrtspclientsink.c(3123): gst_rtsp_client_sink_send (): /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0:
Got error response: 400 (Bad Request).
Execution ended after 0:00:01.071807791
Setting pipeline to NULL ...

In attached files there is a config used with both MediaMTX versions. mediamtx config.txt

Also, in attached files there are logs from both versions of MediaMTX

mtx1.5.log mtx1.8.log

Describe how to replicate the issue

  1. Use provided config
  2. Run MediaMTX v1.8.0

Camera used in reproduction pipeline is AXIS 221

Did you attach the server logs?

yes

Did you attach a network dump?

no

XDGFX commented 2 months ago

I'm having the same issue with the Docker image;

docker run --rm -it --network=host bluenviron/mediamtx:latest

I get the same error when running

gst-launch-1.0 filesrc location=video.mp4 ! qtdemux name=d d.video_0 ! rtspclientsink location=rtsp://127.0.0.1:8554/mystream
Output log ``` Setting pipeline to PAUSED ... Progress: (open) Opening Stream Pipeline is PREROLLED ... Prerolled, waiting for progress to finish... Progress: (connect) Connecting to rtsp://127.0.0.1:8554/mystream ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not open resource for reading and writing. Additional debug info: ../subprojects/gst-rtsp-server/gst/rtsp-sink/gstrtspclientsink.c(3305): gst_rtsp_client_sink_connect_to_server (): /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Failed to connect. (Generic error) ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ... ```

I also can't see any listener on port 8554

lsof  -nP -i | grep 8554

If I run not in host mode and expose the ports I get slightly further, specifically getting a new error ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not get/set settings from/on resource.. This way I do see the service listening on TCP 8554.

docker run --rm -it \
-e MTX_PROTOCOLS=tcp \
-e MTX_WEBRTCADDITIONALHOSTS=192.168.x.x \
-p 8554:8554 \
-p 1935:1935 \
-p 8888:8888 \
-p 8889:8889 \
-p 8890:8890/udp \
-p 8189:8189/udp \
bluenviron/mediamtx
Output log ``` Setting pipeline to PAUSED ... Progress: (open) Opening Stream Progress: (connect) Connecting to rtsp://127.0.0.1:8554/mystream Pipeline is PREROLLED ... Prerolled, waiting for progress to finish... Progress: (open) Retrieving server options Progress: (open) Opened Stream Setting pipeline to PLAYING ... New clock: GstSystemClock Progress: (request) Sending RECORD request Progress: (record) Sending server stream info Progress: (request) SETUP stream 0 Redistribute latency... Redistribute latency... ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not get/set settings from/on resource. Additional debug info: ../subprojects/gst-rtsp-server/gst/rtsp-sink/gstrtspclientsink.c(4307): gst_rtsp_client_sink_setup_streams (): /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not setup transport. Execution ended after 0:00:00.003751000 Setting pipeline to NULL ... Freeing pipeline ... ```

Setting protocols=tcp in rtspclientsink as per https://github.com/bluenviron/mediamtx/issues/2257#issuecomment-1695850914 seems to fix it and the connection succeeds.

Reverting back to host networking, but forcing TCP protocol means we're back to the original issue

docker run --rm -it --network=host -e MTX_PROTOCOLS=tcp -e MTX_WEBRTCADDITIONALHOSTS=192.168.x.x bluen
viron/mediamtx:latest
aler9 commented 2 months ago

@XDGFX your issue is unrelated from this one and is a duplicate of #2257

aler9 commented 2 months ago

@lqbrqt the runOnReady command you are using needs to be edited, you need to change $MTX_PATH_DELAY into ${MTX_PATH}_delay:

runOnReady: >
      gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/$MTX_PATH latency=0
      ! rtpmp4vdepay
      ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=0
      ! rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/${MTX_PATH}_delay

This is because since #3044 environment variables in commands are now replaced by using os.Expand() instead of strings.ReplaceAll().