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
unable to recover playing after doing fast forward of rtsp stream #7472
Comments
Seeking within the cache really shouldn't affect I/O, apart from timing, which could have an effect in less favorable circumstances (but my guess is no). Actually it seems the cache is not kept:
Then it tell libavformat to perform a low level seek, which probably doesn't make sense at all:
libavformat tries to do... something (see rtsp logs, I think it's a Range request which the server dnies), and fails:
It seems it eventually think the stream died.
I don't have a CCTV camera => no reproduction. |
Also if there's only 1 seekable range, I think this discarding shouldn't even happen, could be a bug. |
Oh right, looking at the log and the code again, it's because you seek past the end of the stream. Since mpv thinks the stream is seekable, because libavformat seemed to indicate so (there's no good reporting on whether seeking works by the ffmpeg API), it simply executed that seek, because what else would it do. Normally, if an unseekable "live stream" is played, it would prevent any seeks outside of the cached range. The cached range is discarded because certain properties about the stream make it hard/impossible to resume demuxing when switching back. This is pretty rare and doesn't even really matter in this case. |
should provide working stream for reproduction. |
I could at most blacklist RTSP for seeking (aka another hack to compensate for libavformat's awful "generic" API). Edit: unless you find someone who wants to fix these things in libavformat/FFmpeg (not me). |
ffplay seem to treat this stream as unseekable. I wonder how it detects that (and if mpv can do something similar) |
ffplay also tries to seek, but doesn't reset playback if seeking is reported as failing. This doesn't work for mpv for various reasons; it always resets playback immediately. But on the other hand, ffplay could also get "stuck" and didn't continue playback properly. |
Side note - with this ffmpeg hack I got desired mpv results (seeking in buffer only):
|
Well yeah, we could add that to the format hacks list in demux_lavf.c. There's already an option to "force" seeking anyway, in case anyone really wants to seek in RTSP. I still think that FFmpeg could in theory probe for support in the server code, or use the fact that it's (by declaration in the SDP) a real time stream. (I don't know much about RTSP conventions, though.) |
ffmpeg code parses range header like this:
can't (s->duration == AV_NOPTS_VALUE) condition be used for such detection? From tcpflow trace of my cctv stream:
|
For RTSP, maybe. For other things... I don't know, doesn't seem robust enough. There can actually be files that have no duration set (or have a wrong duration set) and are still seekable, like mkv files. (mkv files use a different demuxer, but it's just an example.) |
Implemented your suggestion. I've seen your patch only later, but the solution is pretty similar anyway. |
Important Information
Provide following Information:
Reproduction steps
Viewing RTSP stream from CCTV camera with buffering enabled.
Fast forward it few times, mpv sees some EOF and now it doesn't recover playing that stream. It is not even possible to rewind into buffered data.
Used config:
Expected behavior
I would expect fast forward to reach end of available stream data but be able to play more when these come in (and don't close that stream... or reopen it to conitnue).
Actual behavior
mpv stops playing and it doesn't show stream anymore but also it is not possible to rewind back to already played and still buffered data.
Log file
First log is:
log-few-forward-presses.txt
Second log is:
log-few-forward-presses-and-then-trying-to-rewind-few-times.txt
Sample files
It's live stream from CCTV camera but I think I should be able to make it visible from the internet if logs are not enough.
The text was updated successfully, but these errors were encountered: