Repository navigation
Add experimental synced playback, and a synced mode to the sample app - #50
Merged
Merged
Conversation
Devices that share a clock can now keep a video on a common timeline. play(asset, startAtMs) puts a clip on the timeline of the controller's GaplessClock, and TimelineKeeper keeps it there while it plays: a late or drifting clip is sped up or slowed down by up to 5%, one that is half a second off seeks, a speed-up never asks the decoder for more than 60 frames a second, and a clip that stalls while sped up isn't sped up again. The API is marked @ExperimentalGaplessApi and needs an opt-in; without a start time playback is unchanged. The sample app gets a sync mode: the leader answers time requests over UDP on the LAN and hands out the playlist and its start, each device works out the same schedule from the shared clock and plays it with start times. samples/sync/compare.py compares two devices' logs at the cuts and during clips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets several devices show the same content in step, for video walls and screens side by side. The library part is experimental and needs
@OptIn(ExperimentalGaplessApi::class); without it nothing changes.Library
play(asset, startAtMs)puts a video on a timeline: its position should be zero atstartAtMson the controller's clock. A new constructor takes that clock as aGaplessClock; otherwise it is the wall clock.play(asset)and the existing constructor are unchanged.TimelineKeeperkeeps the playing clip on its timeline, checked every 250 ms:setprop log.tag.GaplessTimeline DEBUGlogs each anchored clip's distance from its timeline once a second.ExperimentalGaplessApi(opt-in, error level) marksGaplessClock, the clock constructor andplay(asset, startAtMs). The library opts itself in.Sample app
--es sync leaderon one device,--es sync <leader address>on the others. Followers ask the leader for its time over UDP port 47800 about once a second and keep the exchange with the shortest round trip. Replies carry the playlist and when its first slot starts, so each device works out the same schedule with no messages per cut. Monotonic clocks, so a wall clock correction can't move the schedule.--ez anchor falseplays without start times, and--ei lateMs Ncuts late on purpose, for testing.--ez clock trueshows the shared clock and the sync status on screen.samples/sync/compare.pylines up two devices' logs, at the cuts and once a second during clips.Measured on two identical TVs (MediaTek, Android 14), muted, 5 minutes per run
With a late cut, 30 fps clips caught up from 150 ms to under 20 ms within four seconds. Images, web pages and 60 fps clips stay as late as their cut. An earlier version sped 60 fps clips up too; the TV's decoder can't go past 60 frames a second, so they stalled for about two seconds and seeked. The frame rate cap and the stall fallback came from that, and the reruns had no stalls.
Audio was not tested: its start-up delay differs between devices and isn't compensated.