Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback not working as expected using RTSP #3975

Open
matthewroche opened this issue Nov 24, 2024 · 0 comments
Open

Fallback not working as expected using RTSP #3975

matthewroche opened this issue Nov 24, 2024 · 0 comments

Comments

@matthewroche
Copy link

Which version are you using?

MediaMTX v1.9.3

Which operating system are you using?

Linux arm64 standard

Describe how to replicate the issue

I am trying to convert an intermittent RTSP feed (from a battery powered camera) into a continuous feed for consumption by Frigate NVR. I believe there is a bug in how the fallback works, but I may just be misunderstanding its purpose. If this is the case perhaps the documentation around this feature could be improved.

My abbreviated mediamtx.yml is below. (Username and password are obviously populated in use)

rtspAddress: :8552
paths:
  front-door:
    source: rtsp://<username>:<password>@192.168.1.150/live0
    fallback: /fallbackpath
  fallbackpath:
    runOnDemand: ffmpeg -re -loop 1 -i /root/frontdoor-fallback.JPG     -c:v libx265 -f rtsp rtsp://localhost:8552/fallbackpath

When I start the server and read the stream via RTSP whilst the source is unavailable the fallback stream will be displayed correctly. However when the source stream then becomes available the stream delivered by mediamtx does not update unless the stream is reinitialised. Is this expected behaviour, or a bug? Or perhaps have I misconfigured things?

In the logs below you can see mediamtx initialise, then start the FFMPEG fallback stream once the client starts to read the stream (22:16:35). At 22:16:55 you can see the intended source stream becomes available, but this is not reflected in the /front-door stream received by Frigate.

I'm aware there are a few other issues about this feature not working (#1007), but they appear to be different to my experience when reading the RTSP stream

Server logs

Nov 24 22:16:25 frigate-ct systemd[1]: Started mediamtx.service.
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF MediaMTX v1.9.3
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF configuration loaded from /etc/mediamtx/mediamtx.yml
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF [path front-door] [RTSP source] started
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF [RTSP] listener opened on :8552 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF [RTMP] listener opened on :1932
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF [HLS] listener opened on :8888
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP)
Nov 24 22:16:25 frigate-ct mediamtx[1845]: 2024/11/24 22:16:25 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:30 frigate-ct mediamtx[1845]: 2024/11/24 22:16:30 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:34 frigate-ct mediamtx[1845]: 2024/11/24 22:16:34 INF [RTSP] [conn 172.18.0.2:42008] opened
Nov 24 22:16:34 frigate-ct mediamtx[1845]: 2024/11/24 22:16:34 INF [RTSP] [conn 172.18.0.2:42008] closed: EOF
Nov 24 22:16:34 frigate-ct mediamtx[1845]: 2024/11/24 22:16:34 INF [RTSP] [conn 172.18.0.2:42012] opened
Nov 24 22:16:34 frigate-ct mediamtx[1845]: 2024/11/24 22:16:34 INF [path fallbackpath] runOnDemand command started
Nov 24 22:16:35 frigate-ct mediamtx[1879]: ffmpeg version 5.1.6-0+deb12u1 Copyright (c) 2000-2024 the FFmpeg developers
Nov 24 22:16:35 frigate-ct mediamtx[1879]: built with gcc 12 (Debian 12.2.0-14)
Nov 24 22:16:35 frigate-ct mediamtx[1879]: configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libavutil 57. 28.100 / 57. 28.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libavcodec 59. 37.100 / 59. 37.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libavformat 59. 27.100 / 59. 27.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libavdevice 59. 7.100 / 59. 7.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libavfilter 8. 44.100 / 8. 44.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libswscale 6. 7.100 / 6. 7.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libswresample 4. 7.100 / 4. 7.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: libpostproc 56. 6.100 / 56. 6.100
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Input #0, image2, from '/root/frontdoor-fallback.JPG':
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Duration: 00:00:00.04, start: 0.000000, bitrate: 3216 kb/s
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Stream mapping:
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Stream #0:0 -> #0:0 (mjpeg (native) -> hevc (libx265))
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Press [q] to stop, [?] for help
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: HEVC encoder version 3.5+1-f0c1022b6
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: build info [Linux][GCC 12.2.0][64 bit] 8bit+10bit+12bit
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Main profile, Level-2.1 (Main tier)
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Thread pool created using 4 threads
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Slices : 1
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: frame threads / pool features : 2 / wpp(6 rows)
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [warning]: Source height < 720p; disabling lookahead-slices
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 3
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Keyframe min / max / scenecut / bias : 25 / 250 / 40 / 5.00
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: References / ref-limit cu / depth : 3 / off / on
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: Rate Control / qCompress : CRF-28.0 / 0.60
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
Nov 24 22:16:35 frigate-ct mediamtx[1879]: x265 [info]: tools: b-intra strong-intra-smoothing deblock sao
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 INF [RTSP] [conn [::1]:36120] opened
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 INF [RTSP] [session 6cfd5b14] created by [::1]:36120
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 INF [RTSP] [session 6cfd5b14] is publishing to path 'fallbackpath', 1 track (H265)
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Output #0, rtsp, to 'rtsp://localhost:8552/fallbackpath':
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Metadata:
Nov 24 22:16:35 frigate-ct mediamtx[1879]: encoder : Lavf59.27.100
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Stream #0:0: Video: hevc, yuvj420p(pc, bt470bg/unknown/unknown, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 90k tbn
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Metadata:
Nov 24 22:16:35 frigate-ct mediamtx[1879]: encoder : Lavc59.37.100 libx265
Nov 24 22:16:35 frigate-ct mediamtx[1879]: Side data:
Nov 24 22:16:35 frigate-ct mediamtx[1879]: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 INF [RTSP] [session df0e124c] created by 172.18.0.2:42012
Nov 24 22:16:35 frigate-ct mediamtx[1879]: frame= 1 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=N/A
Nov 24 22:16:35 frigate-ct mediamtx[1845]: 2024/11/24 22:16:35 INF [RTSP] [session df0e124c] is reading from path 'fallbackpath', with TCP, 1 track (H265)
Nov 24 22:16:40 frigate-ct mediamtx[1879]: [810B blob data]
Nov 24 22:16:40 frigate-ct mediamtx[1845]: 2024/11/24 22:16:40 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:45 frigate-ct mediamtx[1879]: [733B blob data]
Nov 24 22:16:45 frigate-ct mediamtx[1845]: 2024/11/24 22:16:45 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:50 frigate-ct mediamtx[1879]: [814B blob data]
Nov 24 22:16:50 frigate-ct mediamtx[1845]: 2024/11/24 22:16:50 ERR [path front-door] [RTSP source] bad status code: 404 (Stream Not Found)
Nov 24 22:16:55 frigate-ct mediamtx[1879]: [812B blob data]
Nov 24 22:16:55 frigate-ct mediamtx[1845]: 2024/11/24 22:16:55 WAR [path front-door] [RTSP source] switching to TCP because server requested it
Nov 24 22:16:55 frigate-ct mediamtx[1845]: 2024/11/24 22:16:55 INF [path front-door] [RTSP source] ready: 2 tracks (H264, MPEG-4 Audio)
Nov 24 22:16:55 frigate-ct mediamtx[1845]: 2024/11/24 22:16:55 WAR [path front-door] [RTSP source] 1 RTP packet lost
Nov 24 22:16:56 frigate-ct mediamtx[1879]: [240B blob data]
Nov 24 22:16:56 frigate-ct mediamtx[1845]: 2024/11/24 22:16:56 WAR [path front-door] [RTSP source] 5 RTP packets lost
Nov 24 22:16:57 frigate-ct mediamtx[1879]: frame= 544 fps= 25 q=36.0 size=N/A time=00:00:20.52 bitrate=N/A speed=0.935x
Nov 24 22:16:57 frigate-ct mediamtx[1845]: 2024/11/24 22:16:57 WAR [path front-door] [RTSP source] 1 RTP packet lost
Nov 24 22:16:58 frigate-ct mediamtx[1879]: [159B blob data]
Nov 24 22:16:58 frigate-ct mediamtx[1845]: 2024/11/24 22:16:58 WAR [path front-door] [RTSP source] 2 RTP packets lost
Nov 24 22:16:59 frigate-ct mediamtx[1879]: [158B blob data]
Nov 24 22:16:59 frigate-ct mediamtx[1845]: 2024/11/24 22:16:59 WAR [path front-door] [RTSP source] 1 RTP packet lost

Network dump

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant