mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
26.71k stars 2.84k forks source link

select.lua: preselect the correct sub line with duration >= 100 minutes #14264

Closed guidocella closed 4 weeks ago

guidocella commented 1 month ago

commit 1: select.lua: preselect the correct sub line with duration >= 100 minutes

ffmpeg outputs timestamps like '100:00.00' in LRCs instead of adding hours, and timestamps like '100:00' are < '10:00', so since these strings are being compared, if there is no current subtitle line, there are subtitle lines at >= 100 minutes, and time-pos is between 10 minutes and 100 minutes, one of the last subtitle lines gets preselected.

Fix this by converting the timestamps to numbers before comparing them.

Also simplify the logic by merging the 2 loops to determine the default line, and reformat the timestamps by adding hours to not print minutes > 60 in the selector, and by removing the hundredths of seconds. This requires storing the accurate timestamps in a table to seek to them on submit.

commit 2: select.lua: seek to the currect subtitle line when paused without video

Add an offset to sub seek correctly like in b35e34ae2f. The extra 0.01 offset apparently isn't necessary in this case.

commit 3: select.lua: hide the hour when it's 0

Omit the hour in the chapter and subtitle line selectors when the file is shorter than an hour.

github-actions[bot] commented 1 month ago

Download the artifacts for this pull request:

Windows * [mpv-i686-w64-mingw32](https://nightly.link/mpv-player/mpv/actions/artifacts/1558561361.zip) * [mpv-x86_64-w64-mingw32](https://nightly.link/mpv-player/mpv/actions/artifacts/1558561488.zip) * [mpv-x86_64-windows-msvc](https://nightly.link/mpv-player/mpv/actions/artifacts/1558562382.zip)
macOS * [mpv-macos-12-intel](https://nightly.link/mpv-player/mpv/actions/artifacts/1558558495.zip) * [mpv-macos-13-intel](https://nightly.link/mpv-player/mpv/actions/artifacts/1558559435.zip) * [mpv-macos-14-arm](https://nightly.link/mpv-player/mpv/actions/artifacts/1558557978.zip)