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
12.2k stars 1.53k forks source link

Client RTSP / HEVC Problems with Multiple Clients #1046

Closed josiahbryan closed 2 years ago

josiahbryan commented 2 years ago

Which version are you using?

v0.19.2

Which operating system are you using?

Describe the issue

When running with 2 cameras (inputs) + 4 clients, starting to get errors intermittently in client decoders (note the lines starting with [rtsp @...] and [hevc @...] .

The only thing I've found to help is increasing readBufferCount ... but not sure what values to use there or how high to go. I have it up at 4096 and still getting problems. Should I go higher? Are there other values I can tweak?

(I've tried setting sourceProto to TCP but TCP vs UDP makes no difference on the cameras as far as these errors are concerned)

7-16T20:18:01+00:00: + Add    rfm1328 @31088 d=13 Noned ['rfm1328']
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:18:01+00:00:   <Similarity> Use rfm1328, Skip rfm1328
DEBUG:vgcam_Littlefield_Exit:2022-07-16T20:18:01+00:00: Skip static (30377, 0)
INFO:vgcam_Littlefield_Enterance:2022-07-16T20:18:01+00:00: Health Score: 55%
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq bb43 expected=abac
[hevc @ 0x3f4f380] Could not find ref with POC 0
[hevc @ 0x4074c80] Non-matching NAL types of the VCL NALUs: 1 19
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq ad68 expected=bd04
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq bd68 expected=add0
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:18:02+00:00: Skip static (31112, 0)
[hevc @ 0x4064e80] Could not find ref with POC 18
[hevc @ 0x27f8800] Non-matching NAL types of the VCL NALUs: 1 19
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq ae7b expected=be0f
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq e366 expected=e3d2
[hevc @ 0x406e540] Could not find ref with POC 5
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq be31 expected=ae9d
[hevc @ 0x3f35540] Could not find ref with POC 30
[hevc @ 0x404ae40] The cu_qp_delta -27 is outside the valid range [-26, 25].
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq af5a expected=beed
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq bef8 expected=af66
[hevc @ 0x27f8800] Could not find ref with POC 43
DEBUG:vgcam_Littlefield_Exit:2022-07-16T20:18:03+00:00: Skip static (30404, 0)
INFO:vgcam_Littlefield_Exit:2022-07-16T20:18:04+00:00: Health Score: 50%
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:18:05+00:00: Skip static (31135, 0)
DEBUG:vgcam_Littlefield_Exit:2022-07-16T20:18:06+00:00: Skip static (30432, 0)
INFO:vgcam_Littlefield_Enterance:2022-07-16T20:18:06+00:00: Health Score: 55%
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:18:07+00:00: Skip static (31161, 0)
...
[hevc @ 0x4064e80] Non-matching NAL types of the VCL NALUs: 1 19
[hevc @ 0x406e540] Could not find ref with POC 0
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f091 expected=e0f5
[hevc @ 0x3f35540] Could not find ref with POC 12
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq e181 expected=f119
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq eb78 expected=ebe0
[hevc @ 0x3f35540] Could not find ref with POC 5
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f157 expected=e1c0
[hevc @ 0x3dbcd80] Could not find ref with POC 24
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq e20f expected=f1a5
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq eb7c expected=ebe6
[hevc @ 0x3f35540] Could not find ref with POC 11
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f21c expected=e287
[hevc @ 0x406e540] Could not find ref with POC 37
INFO:vgcam_Littlefield_Exit:2022-07-16T20:20:15+00:00: Health Score: 50%
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq e2f2 expected=f287
[hevc @ 0x4064e80] Could not find ref with POC 22
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq eb84 expected=ebef
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f2e3 expected=e34f
[hevc @ 0x3f4f380] Could not find ref with POC 0
[hevc @ 0x4074c80] Non-matching NAL types of the VCL NALUs: 1 19
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq e6f2 expected=f688
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f69a expected=e704
[hevc @ 0x3f4f380] Could not find ref with POC 12
[hevc @ 0x3f4f380] The cu_qp_delta 101 is outside the valid range [-26, 25].
[hevc @ 0x3dbcd80] Could not find ref with POC 33
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq e7ae expected=f742
INFO:vgcam_Littlefield_Enterance:2022-07-16T20:20:17+00:00: Health Score: 55%
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq eba3 expected=ec0f
[hevc @ 0x404ae40] Could not find ref with POC 22
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq f763 expected=e7cf
[hevc @ 0x4074c80] Could not find ref with POC 48
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:20:18+00:00: Empty (32636, 0)
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:20:18+00:00: Empty (32636, 1)
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:20:19+00:00: + Add    nfm1329 @32646 d=4 Noned ['nfm1329']
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:20:19+00:00:   <Similarity> Use rfm1328, Skip nfm1329
DEBUG:vgcam_Littlefield_Exit:2022-07-16T20:20:19+00:00: Skip static (31850, 0)
DEBUG:vgcam_Littlefield_Enterance:2022-07-16T20:20:20+00:00: Empty (32646, 0)
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq ec52 expected=fbe3
INFO:vgcam_Littlefield_Exit:2022-07-16T20:20:20+00:00: Health Score: 50%
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq fbf1 expected=ec60
[hevc @ 0x3f35540] Could not find ref with POC 19
[hevc @ 0x4074c80] Could not find ref with POC 46
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq ec7e expected=fc10
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq ebc2 expected=ec30
[hevc @ 0x3dbcd80] Could not find ref with POC 22
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq fc57 expected=ecc4
[rtsp @ 0x3d987c0] RTP: PT=60: bad cseq ecd1 expected=fc64
[rtsp @ 0x3d987c0] RTP: PT=61: bad cseq ebc5 expected=ec32

Describe how to replicate the issue

  1. Start server with 2x 4K cameras at full res
  2. Attach Plate Recognizer to both output streams (https://github.com/parkpow/deep-license-plate-recognition)
  3. Attach VLC to both both output streams
  4. Watch logs of Plate Recognizer

Did you attach the server logs?

N/A

Did you attach a network dump?

No

Config being used for the rtsp-simple-server instance (passwords removed):

# With appros port-forwarding and SSH configs,
# can view this on my local mac as:
# /Applications/VLC.app/Contents/MacOS/VLC rtsp://localhost:10554/exit-cam
# /Applications/VLC.app/Contents/MacOS/VLC rtsp://localhost:10554/enter-cam

###############################################
# General parameters

# Sets the verbosity of the program; available values are "error", "warn", "info", "debug".
logLevel: info
# Destinations of log messages; available values are "stdout", "file" and "syslog".
logDestinations: [stdout]
# If "file" is in logDestinations, this is the file which will receive the logs.
logFile: rtsp-simple-server.log

# Timeout of read operations.
readTimeout: 5s
# Timeout of write operations.
writeTimeout: 10s
# Number of read buffers.
# A higher number allows a wider throughput, a lower number allows to save RAM.
readBufferCount: 4096

# HTTP URL to perform external authentication.
# Every time a user wants to authenticate, the server calls this URL
# with the POST method and a body containing:
# {
#   "ip": "ip",
#   "user": "user",
#   "password": "password",
#   "path": "path",
#   "action": "read|publish"
#   "query": "url's raw query"
# }
# If the response code is 20x, authentication is accepted, otherwise
# it is discarded.
externalAuthenticationURL:

# Enable the HTTP API.
api: no
# Address of the API listener.
apiAddress: 127.0.0.1:9997

# Enable Prometheus-compatible metrics.
metrics: no
# Address of the metrics listener.
metricsAddress: 127.0.0.1:9998

# Enable pprof-compatible endpoint to monitor performances.
pprof: no
# Address of the pprof listener.
pprofAddress: 127.0.0.1:9999

# Command to run when a client connects to the server.
# This is terminated with SIGINT when a client disconnects from the server.
# The following environment variables are available:
# * RTSP_PORT: server port
runOnConnect:
# Restart the command if it exits suddenly.
runOnConnectRestart: no

###############################################
# RTSP parameters

# Disable support for the RTSP protocol.
rtspDisable: no
# List of enabled RTSP transport protocols.
# UDP is the most performant, but doesn't work when there's a NAT/firewall between
# server and clients, and doesn't support encryption.
# UDP-multicast allows to save bandwidth when clients are all in the same LAN.
# TCP is the most versatile, and does support encryption.
# The handshake is always performed with TCP.
protocols: [udp, multicast, tcp]
# Encrypt handshake and TCP streams with TLS (RTSPS).
# Available values are "no", "strict", "optional".
encryption: "no"
# Address of the TCP/RTSP listener. This is needed only when encryption is "no" or "optional".
rtspAddress: :8554
# Address of the TCP/TLS/RTSPS listener. This is needed only when encryption is "strict" or "optional".
rtspsAddress: :8322
# Address of the UDP/RTP listener. This is needed only when "udp" is in protocols.
rtpAddress: :8000
# Address of the UDP/RTCP listener. This is needed only when "udp" is in protocols.
rtcpAddress: :8001
# IP range of all UDP-multicast listeners. This is needed only when "multicast" is in protocols.
multicastIPRange: 224.1.0.0/16
# Port of all UDP-multicast/RTP listeners. This is needed only when "multicast" is in protocols.
multicastRTPPort: 8002
# Port of all UDP-multicast/RTCP listeners. This is needed only when "multicast" is in protocols.
multicastRTCPPort: 8003
# Path to the server key. This is needed only when encryption is "strict" or "optional".
# This can be generated with:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
serverKey: server.key
# Path to the server certificate. This is needed only when encryption is "strict" or "optional".
serverCert: server.crt
# Authentication methods.
authMethods: [basic, digest]

###############################################
# RTMP parameters

# Disable support for the RTMP protocol.
rtmpDisable: no
# Address of the RTMP listener.
rtmpAddress: :1935

###############################################
# HLS parameters

# Disable support for the HLS protocol.
hlsDisable: no
# Address of the HLS listener.
hlsAddress: :8888
# By default, HLS is generated only when requested by a user.
# This option allows to generate it always, avoiding the delay between request and generation.
hlsAlwaysRemux: no
# Variant of the HLS protocol to use. Available options are:
# * mpegts - uses MPEG-TS segments, for maximum compatibility.
# * fmp4 - uses fragmented MP4 segments, more efficient.
# * lowLatency - uses Low-Latency HLS.
hlsVariant: mpegts
# Number of HLS segments to keep on the server.
# Segments allow to seek through the stream.
# Their number doesn't influence latency.
hlsSegmentCount: 7
# Minimum duration of each segment.
# A player usually puts 3 segments in a buffer before reproducing the stream.
# The final segment duration is also influenced by the interval between IDR frames,
# since the server changes the duration in order to include at least one IDR frame
# in each segment.
hlsSegmentDuration: 1s
# Minimum duration of each part.
# A player usually puts 3 parts in a buffer before reproducing the stream.
# Parts are used in Low-Latency HLS in place of segments.
# Part duration is influenced by the distance between video/audio samples
# and is adjusted in order to produce segments with a similar duration.
hlsPartDuration: 200ms
# Maximum size of each segment.
# This prevents RAM exhaustion.
hlsSegmentMaxSize: 50M
# Value of the Access-Control-Allow-Origin header provided in every HTTP response.
# This allows to play the HLS stream from an external website.
hlsAllowOrigin: '*'
# Enable TLS/HTTPS on the HLS server.
# This is required for Low-Latency HLS.
hlsEncryption: no
# Path to the server key. This is needed only when encryption is yes.
# This can be generated with:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
hlsServerKey: server.key
# Path to the server certificate.
hlsServerCert: server.crt
# List of IPs or CIDRs of proxies behind the HLS server.
# If the server receives a request from one of these entries, IP in logs
# will be taken from the X-Forwarded-For header.
hlsTrustedProxies: []

###############################################
# Path parameters

# These settings are path-dependent, and the map key is the name of the path.
# It's possible to use regular expressions by using a tilde as prefix.
# For example, "~^(test1|test2)$" will match both "test1" and "test2".
# For example, "~^prefix" will match all paths that start with "prefix".
# The settings under the path "all" are applied to all paths that do not match
# another entry.
paths:
  enter-cam:
    source: rtsp://X:X@192.168.8.5:554/
    # sourceProtocol: udp
  exit-cam:
    source: rtsp://X:X@192.168.8.6:554/
    # sourceProtocol: udp

  all:
    # Source of the stream. This can be:
    # * publisher -> the stream is published by a RTSP or RTMP client
    # * rtsp://existing-url -> the stream is pulled from another RTSP server / camera
    # * rtsps://existing-url -> the stream is pulled from another RTSP server / camera with RTSPS
    # * rtmp://existing-url -> the stream is pulled from another RTMP server
    # * http://existing-url/stream.m3u8 -> the stream is pulled from another HLS server
    # * https://existing-url/stream.m3u8 -> the stream is pulled from another HLS server with HTTPS
    # * redirect -> the stream is provided by another path or server
    source: publisher

    # If the source is an RTSP or RTSPS URL, this is the protocol that will be used to
    # pull the stream. available values are "automatic", "udp", "multicast", "tcp".
    sourceProtocol: automatic

    # Tf the source is an RTSP or RTSPS URL, this allows to support sources that
    # don't provide server ports or use random server ports. This is a security issue
    # and must be used only when interacting with sources that require it.
    sourceAnyPortEnable: no

    # If the source is a RTSPS or HTTPS URL, and the source certificate is self-signed
    # or invalid, you can provide the fingerprint of the certificate in order to
    # validate it anyway. It can be obtained by running:
    # openssl s_client -connect source_ip:source_port </dev/null 2>/dev/null | sed -n '/BEGIN/,/END/p' > server.crt
    # openssl x509 -in server.crt -noout -fingerprint -sha256 | cut -d "=" -f2 | tr -d ':'
    sourceFingerprint:

    # If the source is an RTSP or RTMP URL, it will be pulled only when at least
    # one reader is connected, saving bandwidth.
    sourceOnDemand: no
    # If sourceOnDemand is "yes", readers will be put on hold until the source is
    # ready or until this amount of time has passed.
    sourceOnDemandStartTimeout: 10s
    # If sourceOnDemand is "yes", the source will be closed when there are no
    # readers connected and this amount of time has passed.
    sourceOnDemandCloseAfter: 10s

    # If the source is "redirect", this is the RTSP URL which clients will be
    # redirected to.
    sourceRedirect:

    # If the source is "publisher" and a client is publishing, do not allow another
    # client to disconnect the former and publish in its place.
    disablePublisherOverride: no

    # If the source is "publisher" and no one is publishing, redirect readers to this
    # path. It can be can be a relative path  (i.e. /otherstream) or an absolute RTSP URL.
    fallback:

    # Username required to publish.
    # SHA256-hashed values can be inserted with the "sha256:" prefix.
    publishUser:
    # Password required to publish.
    # SHA256-hashed values can be inserted with the "sha256:" prefix.
    publishPass:
    # IPs or networks (x.x.x.x/24) allowed to publish.
    publishIPs: []

    # Username required to read.
    # SHA256-hashed values can be inserted with the "sha256:" prefix.
    readUser:
    # password required to read.
    # SHA256-hashed values can be inserted with the "sha256:" prefix.
    readPass:
    # IPs or networks (x.x.x.x/24) allowed to read.
    readIPs: []

    # Command to run when this path is initialized.
    # This can be used to publish a stream and keep it always opened.
    # This is terminated with SIGINT when the program closes.
    # The following environment variables are available:
    # * RTSP_PATH: path name
    # * RTSP_PORT: server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnInit:
    # Restart the command if it exits suddenly.
    runOnInitRestart: no

    # Command to run when this path is requested.
    # This can be used to publish a stream on demand.
    # This is terminated with SIGINT when the path is not requested anymore.
    # The following environment variables are available:
    # * RTSP_PATH: path name
    # * RTSP_PORT: server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnDemand:
    # Restart the command if it exits suddenly.
    runOnDemandRestart: no
    # Readers will be put on hold until the runOnDemand command starts publishing
    # or until this amount of time has passed.
    runOnDemandStartTimeout: 10s
    # The command will be closed when there are no
    # readers connected and this amount of time has passed.
    runOnDemandCloseAfter: 10s

    # Command to run when the stream is ready to be read, whether it is
    # published by a client or pulled from a server / camera.
    # This is terminated with SIGINT when the stream is not ready anymore.
    # The following environment variables are available:
    # * RTSP_PATH: path name
    # * RTSP_PORT: server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnReady:
    # Restart the command if it exits suddenly.
    runOnReadyRestart: no

    # Command to run when a clients starts reading.
    # This is terminated with SIGINT when a client stops reading.
    # The following environment variables are available:
    # * RTSP_PATH: path name
    # * RTSP_PORT: server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnRead:
    # Restart the command if it exits suddenly.
    runOnReadRestart: no

And here's the config I'm using for the Plate Recognizer, edited to remove sensitive paths:

# Instructions:
# https://app.platerecognizer.com/stream-docs

# Timezone configuration: https://guides.platerecognizer.com/docs/stream/configuration#timezone
timezone = UTC

[cameras]
  # Full list of regions: http://docs.platerecognizer.com/#countries
  regions = us-tx, us # fr, gb

  # Sample 1 out of X frames. A high number will result in less compute.
  # A low number is preferred for a stream with fast moving vehicles
  sample = 1
  # Setting low due to planned usage of making videos from images

  # Maximum delay in seconds before a prediction is returned
  max_prediction_delay = 2
  # Default 6 - lowering to 2 for better result correlation

  # Maximum time in seconds that a result stays in memory
  memory_decay = 500
  # Default is 300, lowering to X seconds in case the vehicle exits quickly

  # Enable make, model and color prediction. Your account must have that option.
  mmc = false

  # Image file name: https://guides.platerecognizer.com/docs/stream/configuration#image_format
  image_format =
  # Disabled because don't want to save images right now
  # Default: $(camera)_screenshots/%y-%m-%d/%H-%M-%S.%f.jpg

  # Webhook image type. Use "vehicle" to send only the vehicle image or "original" to
  # send the full-size image. This setting can be used at the camera level too.
  webhook_image_type = original

  # When a webhook is sent, the request will time out after n seconds and retry later.
  # webhook_request_timeout = 30

  # Only accept the results that exactly match the templates of the specified regions.
  # region_config = strict

  # Only accept license plates when a vehicle is also detected.
  # detection_rule = strict

  # Beta - Detect vehicles without a license plate. One of: plate, vehicle
  # detection_mode = plate

  # Advanced - Number of steps used to merge unique vehicles. A low number will increase compute.
  # If set to -1, it is automatically picked (default).
  # merge_buffer = -1

  [[vgcam_Littlefield_Enterance]]
    active = yes
    url = rtsp://host.docker.internal:8554/enter-cam
    webhook_targets = https://hosts/webhooks/platerec
    webhook_image = yes
    webhook_caching = no

  [[vgcam_Littlefield_Exit]]
    active = yes
    url = rtsp://host.docker.internal:8554/exit-cam
    webhook_targets = https://host/webhooks/platerec
    webhook_image = yes
    webhook_caching = no
josiahbryan commented 2 years ago

Not sure if this helps at all, but even ffmpeg complains about the stream it's getting (see "Non-monotonous DTS in output stream" below)

This was discovered after adding the ffmpeg command shown in https://github.com/aler9/rtsp-simple-server#save-streams-to-disk for saving streams to disk

2022/07/16 15:55:28 INF [path exit-cam] runOnReady command started
2022/07/16 15:55:28 INF [path exit-cam] [rtsp source] ready
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --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-avresample --enable-videotoolbox
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
2022/07/16 15:55:28 INF [RTSP] [conn [::1]:61624] opened
2022/07/16 15:55:28 INF [RTSP] [session 690179960] created by [::1]:61624
2022/07/16 15:55:28 INF [RTSP] [session 690179960] is reading from path 'exit-cam', 2 tracks with UDP
2022/07/16 15:55:29 INF [RTSP] [conn 127.0.0.1:61625] opened
2022/07/16 15:55:29 INF [RTSP] [session 892534563] created by 127.0.0.1:61625
2022/07/16 15:55:29 INF [RTSP] [session 892534563] is reading from path 'exit-cam', 2 tracks with TCP
Input #0, rtsp, from 'rtsp://localhost:8554/exit-cam':
  Metadata:
    title           : Stream
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: hevc (Main), yuv420p(tv), 3840x2160, 24.92 tbr, 90k tbn, 90k tbc
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[segment @ 0x7ff406813a00] Opening '/tmp/gcap/exit-cam_2022-07-16_15-55-31.ts' for writing
Output #0, segment, to '/tmp/gcap/exit-cam_%Y-%m-%d_%H-%M-%S.ts':
  Metadata:
    title           : Stream
    encoder         : Lavf58.76.100
  Stream #0:0: Video: hevc (Main), yuv420p(tv), 3840x2160, q=2-31, 24.92 tbr, 90k tbn, 90k tbc
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[segment @ 0x7ff406813a00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x7ff406813a00] Non-monotonous DTS in output stream 0:0; previous: 5296621, current: 5290985; changing to 5296622. This may result in incorrect timestamps in the output file.
[segment @ 0x7ff406813a00] Non-monotonous DTS in output stream 0:0; previous: 5296622, current: 5294592; changing to 5296623. This may result in incorrect timestamps in the output file.
[segment @ 0x7ff406813a00] Opening '/tmp/gcap/exit-cam_2022-07-16_15-56-30.ts' for writing
[segment @ 0x7ff406813a00] Non-monotonous DTS in output stream 0:0; previous: 8892995, current: 8886910; changing to 8892996. This may result in incorrect timestamps in the output file.
[segment @ 0x7ff406813a00] Non-monotonous DTS in output stream 0:0; previous: 8892996, current: 8890517; changing to 8892997. This may result in incorrect timestamps in the output file.
[segment @ 0x7ff406813a00] Opening '/tmp/gcap/exit-cam_2022-07-16_15-57-30.ts' for writing
josiahbryan commented 2 years ago

Any traction on this issue? Major problem and blocker for us

aler9 commented 2 years ago

Hello, The server uses a ring buffer (https://en.wikipedia.org/wiki/Circular_buffer) in order to read streams from cameras and write streams to readers. readBufferCount is used to tune the size of that buffer and indicates the maximum number of packets that are kept into the server, waiting to be sent to clients.

If you're having problems when the number of connected clients increases, it means that there's a bottleneck, either at the CPU level or at the network level, and the ring buffer can't keep up and starts discarding packets. It happens when the server isn't able to read or write packets fast enough.

You can

github-actions[bot] commented 1 year ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.