https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
l

louiscad

04/02/2024, 12:55 AM
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

soufianehamama9

04/02/2024, 3:57 AM
Try libVLC
m

mohamed rejeb

04/02/2024, 4:49 AM
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

Landry Norris

04/02/2024, 12:13 PM
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

louiscad

04/02/2024, 12:28 PM
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.