flutter_vlc_player icon indicating copy to clipboard operation
flutter_vlc_player copied to clipboard

Feature Request: Expose decoded frame timestamp (PTS) to Flutter layer

Open guoxiao0521 opened this issue 3 months ago • 0 comments

Feature Request — Expose Decoded Frame Timestamp (PTS/DTS)

Expected Feature

In flutter_vlc_player, I would like to have access to the timestamp of each decoded (or soon-to-be-rendered) frame, such as PTS (presentation timestamp) or DTS (decoding timestamp).

Background / Use Cases

  • Synchronizing video frames with external data sources (e.g., sensor data, subtitles, annotations).
  • Performing frame-level video analysis that requires precise playback timing for each frame.
  • Currently, the plugin provides playback control, screenshots, seek, and recording, but no API to obtain frame timestamps.

Suggested API Design

  • Provide a frame timestamp callback (via EventChannel) that emits the timestamp each time a frame is decoded or about to be rendered.
  • Alternatively, include the timestamp when fetching a frame/screenshot/texture.
  • The timestamp unit could be milliseconds or microseconds, based on libVLC’s internal PTS representation.

Implementation Notes

  • Android: hook into libVLC JNI frame/renderer callbacks, which contain PTS or related timing info.
  • iOS: use VLCKit’s equivalent APIs to extract frame timestamps.
  • Pass these timestamps back to the Dart layer using MethodChannel or EventChannel.

Difference from Existing Features

  • Current flutter_vlc_player features: playback, pause, seek, screenshot, recording.
  • Missing: fine-grained per-frame timing information.
  • This feature would unlock new use cases involving synchronization and analysis.

Potential Considerations

  • Performance cost: frequent callbacks (per frame) may introduce overhead.
  • Platform differences: libVLC vs. VLCKit APIs may differ in timestamp handling.
  • Consistency: need to clearly define what timestamp type is exposed (PTS, presentation time, or stream time).

🙏 Thanks for considering this request! If maintainers are open to it, I’d be happy to help with a PoC or PR on the native layer.

guoxiao0521 avatar Sep 22 '25 08:09 guoxiao0521