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

fix: timeline when rebase-start-time=no #969

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

po5
Copy link
Contributor

@po5 po5 commented Sep 1, 2024

We would end up with a playback-time way past the reported duration on some files when using --rebase-start-time=no, which would break the timeline display and produce seeks that were outside the playable range of the video.

Sample generated with streamlink -o lol.ts https://www.twitch.tv/rubius 1080p50: https://0x0.st/XwrB.ts

Before
lol ts_023847 200
After
lol ts_023847 200_

@po5
Copy link
Contributor Author

po5 commented Sep 1, 2024

There probably is a nicer way to write the conditions, this is the first thing I came up with.

@tomasklaen
Copy link
Owner

Setting/normalizing duration shouldn't happen in update_human_times(). Do something like this instead:

diff --git a/src/uosc/main.lua b/src/uosc/main.lua
index f1265d7..d60eba3 100644
--- a/src/uosc/main.lua
+++ b/src/uosc/main.lua
@@ -450,6 +450,12 @@ function update_fullormaxed()
 	cursor:leave()
 end
 
+function update_duration()
+	state.duration = state._duration and ((state.rebase_start_time == false and state.start_time)
+		and (state._duration + state.start_time) or state._duration)
+	update_human_times()
+end
+
 function update_human_times()
 	state.speed = state.speed or 1
 	if state.time then
@@ -723,7 +729,9 @@ mp.observe_property('playback-time', 'number', create_state_setter('time', funct
 	update_human_times()
 	select_current_chapter()
 end))
-mp.observe_property('duration', 'number', create_state_setter('duration', update_human_times))
+mp.observe_property('rebase-start-time', 'bool', create_state_setter('rebase_start_time', update_duration))
+mp.observe_property('demuxer-start-time', 'number', create_state_setter('start_time', update_duration))
+mp.observe_property('duration', 'number', create_state_setter('_duration', update_duration))
 mp.observe_property('speed', 'number', create_state_setter('speed', update_human_times))
 mp.observe_property('track-list', 'native', function(name, value)
 	-- checks the file dispositions

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.

2 participants