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

demux_lavf: set duration to -1 if unknown #12457

Merged
merged 1 commit into from Sep 22, 2023

Conversation

llyyr
Copy link
Contributor

@llyyr llyyr commented Sep 21, 2023

demux->duration is set to -1 on initialization, and some checks rely on it being -1 when unknown. Before this commit, we set demux->duration to 0 when unknown. This is incorrect and breaks rtsp logic for disabling seeking outside of cached regions.

To fix these issues, initialize total_duration and av_duration at -1. They're only changed if a real duration is detected, so in cases where the duration is unknown, demux->duration is set to -1 correctly.

Fixes: e6afc53 ("demux_lavf: get total duration from track durations")
Fixes #12454

Copy link
Member

@Dudemanguy Dudemanguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable

@llyyr
Copy link
Contributor Author

llyyr commented Sep 21, 2023

@myspaghetti can you try testing with the mpv build from this PR to see if this fixes your issue? https://github.com/mpv-player/mpv/actions/runs/6265175874

@github-actions
Copy link

github-actions bot commented Sep 21, 2023

Download the artifacts for this pull request:

Windows

demux/demux_lavf.c Outdated Show resolved Hide resolved
`demux->duration` is set to -1 on initialization, and some checks rely
on it being -1 when unknown. Before this commit, we set
`demux->duration` to 0 when unknown. This is incorrect and breaks rtsp
logic for disabling seeking outside of cached regions.

To fix these issues, initialize `total_duration` and `av_duration` at
-1. They're only changed if a real duration is detected, so in cases
where the duration is unknown, demux->duration is set to -1 correctly.

Fixes: e6afc53 ("demux_lavf: get total duration from track durations")
@myspaghetti
Copy link

This build seeks correctly, thank you!

(Playback is more jerky, frames are unnecessarily skipped when skipping or fast-forwarding, fps appears to be limited to stream fps instead of display fps, but this appears to be a different issue.)

Thank you so much! You addressed this issue remarkably fast!

@llyyr
Copy link
Contributor Author

llyyr commented Sep 22, 2023

More time was spent trying to get a working rtsp stream than figuring out the bug...

Thanks for testing.

@sfan5 sfan5 merged commit 84d6044 into mpv-player:master Sep 22, 2023
14 checks passed
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

Successfully merging this pull request may close these issues.

regression in seeking streams with no PTS with --no-correct-pts
4 participants