love icon indicating copy to clipboard operation
love copied to clipboard

Expose VideoStream Sync objects

Open MikuAuahDark opened this issue 2 years ago • 2 comments

Currently, VideoStream syncs with either Source position or automatically incremented based on the delta-time. Would it be a good idea to have these exposed to user?

My use case is to play video with custom delta sync that I'd like to increment myself for offline rendering purpose. My previous approach was to always seeking paused video such that it renders correct frame, but this approach causes distortion to the drawn video (like in #1477).

My proposal is to have VideoSync abstract class. This class doesn't have any methods. Then the VideoStream class accepts VideoSync class for the VideoStream:setSync method. The VideoStream:getSync retrieves the current VideoSync object used.

For the actual implementation of VideoSync class, there are SourceSync that uses audio Source for their sync or DeltaSync that uses delta time which can be incremented either by user (DeltaSync:update(dt)) or by LOVE itself.

Using silent Source file for workaround is not ideal as it's hard to determine the video duration (parsing Theora packets is hard).

MikuAuahDark avatar Apr 18 '22 03:04 MikuAuahDark

One tricky thing with this is I don't believe it's possible for a DeltaSync to drive audio playback speed/position. So if users are able to change and manipulate the Sync object associated with a video, DeltaSync would de-sync audio from video in situations where a video has audio.

Maybe there needs to be a higher level API for what you want, or something.

slime73 avatar Apr 21 '22 23:04 slime73

I think if user changes the sync object of a video stream then users can expect desync to happen. Of course if the video is created with audio, SourceSync is used by default, which keeps audio and video synchronized.

MikuAuahDark avatar Apr 22 '22 01:04 MikuAuahDark