Video Frame
August 5, 2026 · View on GitHub
Translations: 简体中文
Sketch provides the sketch-video-* series of modules to support decoding video frames
| Module | Decoder | Android | iOS | macOS Native | Desktop | Web |
|---|---|---|---|---|---|---|
| sketch-video | VideoFrameDecoder PhotosAssetVideoFrameDecoder FileVideoFrameDecoder | ✅(API 27) | ✅ | ✅ | ❌ | ❌ |
| sketch-video-ffmpeg | FFmpegVideoFrameDecoder | ✅ | ❌ | ❌ | ❌ | ❌ |
- 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:
- Decode video frames using the FFmpegMediaMetadataRetriever class of the wseemann/FFmpegMediaMetadataRetriever-project library
- Library size is approximately 23 MB
- 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}: (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)
}