rtspclientsink is unable to automatically switch to TCP
Author: xunleiwCreated Aug 27, 2023Updated Sep 30, 2026
Labelsbugrtsp
Which version are you using?
v1.0.0
Which operating system are you using?
- Linux amd64 standard
- Linux amd64 Docker
- Linux arm64 standard
- Linux arm64 Docker
- Linux arm7 standard
- Linux arm7 Docker
- Linux arm6 standard
- Linux arm6 Docker
- Windows amd64 standard
- Windows amd64 Docker (WSL backend)
- macOS amd64 standard
- macOS amd64 Docker
- Other (please describe)
Describe the issue
Description
Describe how to replicate the issue
start the server on a Linux AMD64 machine (following https://github.com/bluenviron/mediamtx#docker-image) with
docker run --rm -it \ -e MTX_PROTOCOLS=tcp \ -p 8554:8554 \ -p 1935:1935 \ -p 8888:8888 \ -p 8889:8889 \ -p 8890:8890/udp \ bluenviron/mediamtxOn the same machine, publish with the sample code (following https://github.com/bluenviron/mediamtx#opencv) with
from datetime import datetime
from time import sleep, time
import cv2
import numpy as np
fps = 15
width = 800
height = 600
colors = [
(0, 0, 255),
(255, 0, 0),
(0, 255, 0),
]
out = cv2.VideoWriter('appsrc ! videoconvert' + \
' ! video/x-raw,format=I420' + \
' ! x264enc speed-preset=ultrafast bitrate=600 key-int-max=' + str(fps * 2) + \
' ! video/x-h264,profile=baseline' + \
' ! rtspclientsink location=rtsp://localhost:8554/mystream',
cv2.CAP_GSTREAMER, 0, fps, (width, height), True)
if not out.isOpened():
raise Exception("can't open video writer")
curcolor = 0
start = time()
while True:
frame = np.zeros((height, width, 3), np.uint8)
# create a rectangle
color = colors[curcolor]
curcolor += 1
curcolor %= len(colors)
for y in range(0, int(frame.shape[0] / 2)):
for x in range(0, int(frame.shape[1] / 2)):
frame[y][x] = color
out.write(frame)
print("%s frame written to the server" % datetime.now())
now = time()
diff = (1 / fps) - now - start
if diff > 0:
sleep(diff)
start = now- encounter error
$ python3 mediamtx_example.py
2023-08-27 20:35:11.848800 frame written to the server
2023-08-27 20:35:11.911849 frame written to the server
2023-08-27 20:35:11.973843 frame written to the server
2023-08-27 20:35:12.036632 frame written to the server
2023-08-27 20:35:12.099610 frame written to the server
2023-08-27 20:35:12.164734 frame written to the server
2023-08-27 20:35:12.226825 frame written to the server
2023-08-27 20:35:12.288597 frame written to the server
2023-08-27 20:35:12.352552 frame written to the server
2023-08-27 20:35:12.415639 frame written to the server
2023-08-27 20:35:12.477339 frame written to the server
2023-08-27 20:35:12.544070 frame written to the server
2023-08-27 20:35:12.611003 frame written to the server
2023-08-27 20:35:12.674039 frame written to the server
2023-08-27 20:35:12.735689 frame written to the server
2023-08-27 20:35:12.800361 frame written to the server
2023-08-27 20:35:12.865514 frame written to the server
2023-08-27 20:35:12.929776 frame written to the server
2023-08-27 20:35:12.995239 frame written to the server
2023-08-27 20:35:13.057389 frame written to the server
[ WARN:[email protected]] global cap_gstreamer.cpp:2784 handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module rtspclientsink0 reported: Could not get/set settings from/on resource.
[ WARN:[email protected]] global cap_gstreamer.cpp:2676 writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline
2023-08-27 20:35:13.134441 frame written to the server
[ WARN:[email protected]] global cap_gstreamer.cpp:2676 writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline
...Did you attach the server logs?
yes
$ docker run --rm -it -e MTX_PROTOCOLS=tcp -p 8554:8554 -p 1935:1935 -p 8888:8888 -p 8889:8889 -p 8890:8890/udp bluenviron/mediamtx
2023/08/27 20:43:07 INF MediaMTX v1.0.0
2023/08/27 20:43:07 INF [RTSP] listener opened on :8554 (TCP)
2023/08/27 20:43:07 INF [RTMP] listener opened on :1935
2023/08/27 20:43:07 INF [HLS] listener opened on :8888
2023/08/27 20:43:07 INF [WebRTC] listener opened on :8889 (HTTP)
2023/08/27 20:43:07 INF [SRT] listener opened on :8890 (UDP)
2023/08/27 20:43:12 INF [RTSP] [conn 10.32.187.30:52082] opened
2023/08/27 20:43:13 INF [RTSP] [session 87b3c481] created by 10.32.187.30:52082
2023/08/27 20:43:13 INF [RTSP] [conn 10.32.187.30:52082] closed (EOF)
2023/08/27 20:43:13 INF [RTSP] [session 87b3c481] destroyed (not in use)Did you attach a network dump?
no
Source: bluenviron/mediamtx