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
11.64k stars 1.47k forks source link

[BUG] Re-encoding a video stream using runOnReady and ffmpeg is not publishing to my path #3686

Open Martayugui opened 3 weeks ago

Martayugui commented 3 weeks ago

Which version are you using?

v0.0.0

Which operating system are you using?

Describe the issue

I am reading video streams via a web browser (firefox) using WebRTC protocol. The publisher is sending H264 streams with B-frames so I am getting the following error "WebRTC doesn't support H264 streams with B-frames". I would like to use WebRTC because I need low latency. Now I am trying to re-encoding the incoming video stream packets with runOnReady to disable Bframes but this error is showing up "no one is publishing to path 'mypath'"

Describe how to replicate the issue

  1. Start the server: Mediamtx.yml paths: compressed: mypath: runOnReady: ffmpeg -i udp://127.0.0.1:5546/mypath -c:v libx264 -bf 0 -f rtsp rtsp://127.0.0.1:5546/compressed runOnReadyRestart: yes

  2. Publish with (customised script): Run reply.py tool that uses a hex video file and publish it to a socket (IP: 127.0.0.1, PORT: 5546) ./replay.py h264-400kbit.hex 127.0.0.1 5546

  3. Read with (firefox browser): http://localhost:8889/mypath

Did you attach the server logs?

2024/08/23 22:51:20 INF MediaMTX v0.0.0 2024/08/23 22:51:20 INF configuration loaded from /home/pc03/5G-V2X/mediamtx/mediamtx.yml 2024/08/23 22:51:20 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP) 2024/08/23 22:51:20 INF [RTMP] listener opened on :1935 2024/08/23 22:51:20 INF [HLS] listener opened on :8888 2024/08/23 22:51:20 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP) 2024/08/23 22:51:20 INF [SRT] listener opened on :8890 (UDP) 2024/08/23 22:51:22 INF [WebRTC] [session c6a2115f] created by 127.0.0.1:48988 2024/08/23 22:51:22 INF [WebRTC] [session c6a2115f] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:24 INF [WebRTC] [session d46ae20c] created by 127.0.0.1:48988 2024/08/23 22:51:24 INF [WebRTC] [session d46ae20c] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:26 INF [WebRTC] [session fba3bda3] created by 127.0.0.1:48988 2024/08/23 22:51:26 INF [WebRTC] [session fba3bda3] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:28 INF [WebRTC] [session 6641799e] created by 127.0.0.1:48988 2024/08/23 22:51:28 INF [WebRTC] [session 6641799e] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:30 INF [WebRTC] [session 8ea15ad5] created by 127.0.0.1:48988 2024/08/23 22:51:30 INF [WebRTC] [session 8ea15ad5] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:32 INF [WebRTC] [session 78af56bb] created by 127.0.0.1:48988 2024/08/23 22:51:32 INF [WebRTC] [session 78af56bb] closed: no one is publishing to path 'mypath' 2024/08/23 22:51:34 INF [WebRTC] [session 1e66ff8b] created by 127.0.0.1:48988 2024/08/23 22:51:34 INF [WebRTC] [session 1e66ff8b] closed: no one is publishing to path 'mypath'

Did you attach a network dump?

no

Martayugui commented 2 weeks ago

I have tried with runOnInit and it partially worked. However, I would like to use runOnReady because it meets my requirements:

paths: compressed: original: source: publisher runOnInit: > ffmpeg -i udp://127.0.0.1:5546 -c:v libx264 -bf 0 -f rtsp rtsp://localhost:8554/compressed

if publisher sends several packets consecutively, it raises this error:

2024/08/25 21:19:44 INF [WebRTC] [session 8e0b6bc3] is reading from path 'compressed', 1 track (H264) 2024/08/25 21:19:56 INF [RTSP] [conn 127.0.0.1:48512] closed: terminated.72x 2024/08/25 21:19:56 INF [RTSP] [session 1b3d771c] destroyed: session timed out 2024/08/25 21:19:56 INF [WebRTC] [session 8e0b6bc3] closed: terminated av_interleaved_write_frame(): Broken pipe

thank you in advance