harlanc / xiu

A simple,high performance and secure live media server in pure Rust (RTMP[cluster]/RTSP/WebRTC[whip/whep]/HTTP-FLV/HLS).🦀
https://www.rustxiu.com
MIT License
1.6k stars 168 forks source link

RTSP stream crashes and can't restart #115

Open SaulMoonves opened 2 months ago

SaulMoonves commented 2 months ago

XIU version v0.12.6

Describe the bug I am using the ffmpeg streaming command from the docs for RTSP. After a while, the stream crashes and then you are unable to start the stream again on the same URL and xiu has to be restarted.

To Reproduce

ffmpeg -re -stream_loop -1  -i my-file.mp4 -c:v copy  -c:a copy  -rtsp_transport tcp -f rtsp "rtsp://my-server/live/test?token=123"

It works for a while then crashes with:

[out#0/rtsp @ 0x600002da8780] Could not write header (incorrect codec parameters ?): Invalid data found when processing input
Error opening output file <url>.
Error opening output files: Invalid data found when processing input

Backend says:

Apr 04 10:15:02 falco xiu[32042]: [2024-04-04T10:15:02Z ERROR xrtsp::rtsp] session run error, err: bytes read error: not enough bytes to read
Apr 04 10:29:17 falco xiu[32042]: [2024-04-04T10:29:17Z DEBUG xrtsp::session] dollar sign: false
Apr 04 10:29:17 falco xiu[32042]: [2024-04-04T10:29:17Z DEBUG xrtsp::session] dollar sign: false
Apr 04 10:29:18 falco xiu[32042]: [2024-04-04T10:29:18Z INFO  xrtsp::session] media_name: video
Apr 04 10:29:18 falco xiu[32042]: thread 'tokio-runtime-worker' panicked at protocol/rtsp/src/session/mod.rs:679:26:
Apr 04 10:29:18 falco xiu[32042]: called `Option::unwrap()` on a `None` value
Apr 04 10:29:18 falco xiu[32042]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It is doing this with every file I try. After this happens I have to restart xiu because retrying doesn't work after that point.

Expected behavior no errors