Hello! Is there a preferred way to play video insi...
# compose-desktop
l
Hello! Is there a preferred way to play video inside Compose Desktop? 📺 I'm looking for: • programmatic playback control with frame-level precision • non horrible API • efficiency (hardware acceleration whenever possible, but that's probably in all solutions)
s
Try libVLC
m
I tried vlc4j and the frames are not precise, specially if it's not the first time you play the video. JavaFx player is returning correct values about the current position but sometimes seeking is not precise (ex: you choose 2000millis and it seeks to 1800 millis)
l
FFmpeg will give you frame-level precision, but that definitely doesn't pass the 'non-horrible API' criteria
The tough thing about frame-level precision is that you can only actually move directly to a key frame. To get to any other frame, you have to move to the last key frame before, then step forward. This can be slow, but can be mitigated by buffering more frames, but there's a lot of tradeoffs there, so it's tough to have a high-level API that will give you the tradeoffs you want.
👆 1
l
It should be doable with a coroutines bases construct. Something like that:
Copy code
fun liveFrame(timestamp: Flow<FrameTimestamp>): Flow<FrameResult>
Thanks to the Flow semantics, the implementation of this function is free to do internal optimizations as the given
FrameTimestamp
is seeked forward, or backwards while the Flow is still being collected.