Video Frame

August 5, 2026 · View on GitHub

Translations: 简体中文

Sketch provides the sketch-video-* series of modules to support decoding video frames

ModuleDecoderAndroidiOSmacOS NativeDesktopWeb
sketch-videoVideoFrameDecoder
PhotosAssetVideoFrameDecoder
FileVideoFrameDecoder
✅(API 27)
sketch-video-ffmpegFFmpegVideoFrameDecoder
  • VideoFrameDecoder:
    • Decode video frames using Android's built-in MediaMetadataRetriever class
    • It is recommended to use Android 8.1 and above, because versions 8.0 and below do not support reading frame thumbnails, which will consume a lot of memory when decoding larger videos such as 4k.
    • Only supports Android
  • FFmpegVideoFrameDecoder:
  • PhotosAssetVideoFrameDecoder
    • Use the AVAssetImageGenerator class to decode video frames
    • Only URIs starting with file:///photos_asset/ are supported
    • Only supports the iOS platform
  • FileVideoFrameDecoder
    • Use the AVAssetImageGenerator class to decode video frames
    • Only local path uri is supported
    • Supports iOS and macOS Native

Install component

${LAST_VERSION}: Download (Not included 'v')

implementation("io.github.panpf.sketch4:sketch-video:${LAST_VERSION}")
// or
implementation("io.github.panpf.sketch4:sketch-video-ffmpeg:${LAST_VERSION}")

Important

The above components all support automatic registration. You only need to import them without additional configuration. If you need to register manually, please read the documentation: 《Register component》

Configuration

ImageRequest and ImageOptions support some video frame-related configurations, as follows:

ImageRequest(context, "file:///sdcard/sample.mp4") {
    // Extract the frame at 1000000 microseconds
    videoFrameMicros(1000000)

    // or extract the frame at 10000 ms
    videoFrameMillis(10000)

    // or get the frames in between
    videoFramePercent(0.5f)

    // Get embedded covers first
    preferVideoCover(true)

    // Set the processing strategy when frames cannot be extracted at the specified time. Android platform only
    videoFrameOption(MediaMetadataRetriever.OPTION_CLOSEST)
}