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

Fallback doesn't work on HLS #1007

Open leap0x7b opened 2 years ago

leap0x7b commented 2 years ago

Which version are you using?

v0.19.2

Which operating system are you using?

Describe the issue

All paths in RTSP sends fallbacks correctly when there's no source but not HLS.

Describe how to replicate the issue

  1. start the server
  2. publish with RTSP
  3. read with HLS

Did you attach the server logs?

2022/06/27 06:43:18 INF rtsp-simple-server v0.19.2
2022/06/27 06:43:18 INF [path fallback] runOnInit command started
2022/06/27 06:43:18 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/06/27 06:43:18 INF [RTMP] listener opened on :1935
2022/06/27 06:43:18 INF [HLS] listener opened on :8888
2022/06/27 06:43:18 INF [API] listener opened on 127.0.0.1:9997
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with Android (7714059, based on r416183c1) clang version 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)
  configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --pkg-config=/home/builder/.termux-build/_cache/android-r23b-api-24-v9/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libgme --enable-libmp3lame --enable-libfreetype --enable-libvorbis --enable-libopus --enable-librav1e --enable-libsoxr --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvidstab --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libtheora --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, rawvideo, from '/dev/zero':
  Duration: N/A, start: 0.000000, bitrate: 1244160 kb/s
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080, 1244160 kb/s, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x77ec22e400] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x77ec22e400] profile High 4:4:4 Predictive, level 4.0, 4:4:4, 8-bit
[libx264 @ 0x77ec22e400] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
2022/06/27 06:43:19 INF [RTSP] [conn 127.0.0.1:51174] opened
2022/06/27 06:43:19 INF [RTSP] [session 535294575] created by 127.0.0.1:51174
[udp @ 0x77ec224100] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0x77ec2241a0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
2022/06/27 06:43:19 INF [RTSP] [session 535294575] is publishing to path 'fallback', 1 track with UDP
2022/06/27 06:43:19 INF [HLS] [muxer fallback] created automatically
2022/06/27 06:43:19 INF [HLS] [muxer fallback] is converting into HLS
Output #0, rtsp, to 'rtsp://localhost:8554/fallback':
  Metadata:
    encoder         : Lavf59.16.100
  Stream #0:0: Video: h264, yuv444p(tv, progressive), 1920x1080, q=2-31, 25 fps, 90k tbn
    Metadata:
      encoder         : Lavc59.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
2022/06/27 06:43:41 INF [HLS] [muxer tv] created (requested by 127.0.0.1)329x
2022/06/27 06:43:41 INF [HLS] [muxer tv] destroyed (no one is publishing to path 'tv')
2022/06/27 06:43:49 INF [HLS] [muxer tv] created (requested by 127.0.0.1)362x
2022/06/27 06:43:49 INF [HLS] [muxer tv] destroyed (no one is publishing to path 'tv')
^C2022/06/27 06:44:29 INF shutting down gracefully60 bitrate=N/A speed=0.408x
2022/06/27 06:44:29 INF [RTSP] [session 535294575] destroyed (terminated)
2022/06/27 06:44:29 INF [HLS] [muxer fallback] destroyed (terminated)
2022/06/27 06:44:29 INF [path fallback] runOnInit command stopped
2022/06/27 06:44:29 INF [API] listener is closing
2022/06/27 06:44:29 INF [RTSP] [conn 127.0.0.1:51174] closed (terminated)
2022/06/27 06:44:29 INF [RTSP] listener is closing
2022/06/27 06:44:29 INF [HLS] listener is closing
2022/06/27 06:44:29 INF [RTMP] listener is closing
2022/06/27 06:44:29 INF waiting for external commands
av_interleaved_write_frame(): Broken pipe
frame=  777 fps= 11 q=28.0 Lsize=N/A time=00:00:28.72 bitrate=N/A speed=0.398x
video:52kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x77ec22e400] frame I:4     Avg QP: 6.75  size:   492
[libx264 @ 0x77ec22e400] frame P:196   Avg QP: 9.10  size:    77
[libx264 @ 0x77ec22e400] frame B:577   Avg QP:12.67  size:    69
[libx264 @ 0x77ec22e400] consecutive B-frames:  0.9%  0.3%  0.0% 98.8%
[libx264 @ 0x77ec22e400] mb I  I16..4:  0.0% 100.0%  0.0%
[libx264 @ 0x77ec22e400] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0x77ec22e400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%
[libx264 @ 0x77ec22e400] 8x8 transform intra:100.0%
[libx264 @ 0x77ec22e400] coded y,u,v intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x77ec22e400] i16 v,h,dc,p:  0%  0% 100%  0%
[libx264 @ 0x77ec22e400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x77ec22e400] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x77ec22e400] kb/s:14.58
Exiting normally, received signal 2.

Did you attach a network dump?

no

sgofferj commented 1 year ago

RTMP also doesn't work. I have the following config:

paths:
  logo:
    runOnInit: ffmpeg -re -loop 1 -framerate 25 -i /logo_320.png -c:v libx264 -pix_fmt yuv420p -vf scale=320:240 -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
  wolfman:
    source: publisher
    fallback: /logo

I can connect to /logo and it works fine but if I try to connect to wolfman, no matter if rtsp, rtmp or hls I get nothing. Example log entries:

2023/04/24 06:52:46 INF [RTMP] [conn 192.168.10.1:48030] opened
2023/04/24 06:52:46 INF [RTMP] [conn 192.168.10.1:48030] closed (no one is publishing to path 'wolfman')
zeridon commented 1 year ago

Same here. Fallback does not start at all:

rtsp: no
webrtc: no
srt: no

rtmp: yes
rtmpAddress: :1935
rtmpEncryption: "no"

hls: yes
hlsAddress: :8080
hlsAlwaysRemux: yes
hlsVariant: mpegts
hlsSegmentCount: 10
hlsSegmentDuration: 1s
hlsPartDuration: 200ms
hlsSegmentMaxSize: 50M

paths:
  nostream:
    runOnInit: ffmpeg -re -stream_loop -1 -i ./nostream.flv -c copy -f flv rtmp://localhost:1935/nostream
    runOnInitRestart: yes

  "~^demo/":
    source: publisher
    sourceOnDemand: no
    sourceOnDemandStartTimeout: 10s
    sourceOnDemandCloseAfter: 10s
    overridePublisher: yes
    fallback: /nostream