π¬ Video Thumb Kit
Fast, cross-platform video thumbnail generation for Flutter.
Turn a video file, URL, or raw byte array into a crisp thumbnail β as a file or in memory β with a few lines of Dart.
π Table of contents
- β¨ Features
- π± Platform support
- π¦ Installation
- π Quick start
- π§° API reference
- πͺ Windows notes
- π‘ Example use cases
- π€ Contributing
- β Support this project
β¨ Features
- πΌοΈ Generate thumbnails from video files or raw byte arrays
- π¨ Multiple image formats β
PNG,JPG, andWebP - π Fully customizable size, quality, and timestamp
- β‘ Native platform implementations for optimal performance
- πΎ Get a thumbnail back as a file path or an in-memory
Uint8List
π± Platform support
| Platform | thumbnailFile |
thumbnailData |
thumbnailDataWeb |
|---|---|---|---|
| π€ Android | β | β | βοΈ |
| π iOS | β | β | βοΈ |
| π₯οΈ macOS | β | β | βοΈ |
| πͺ Windows | β | β | βοΈ |
| π Web | βοΈ | βοΈ | β |
iOS / macOS: iOS and macOS share a single native implementation under darwin/, integrable via either CocoaPods or Swift Package Manager. Minimum versions: iOS 13.0+, macOS 10.15+.
π¦ Installation
Add video_thumb_kit to your pubspec.yaml:
dependencies:
video_thumb_kit: ^0.0.1
Then fetch it:
flutter pub get
π Quick start
1οΈβ£ Generate a thumbnail file
import 'package:video_thumb_kit/video_thumb_kit.dart';
Future<void> main() async {
final videoPath = 'path/to/video.mp4';
final thumbnailPath = 'path/to/thumbnail.png';
final result = await VideoThumbKit.thumbnailFile(
video: videoPath,
thumbnailPath: thumbnailPath,
imageFormat: ImageFormat.png,
maxHeight: 100,
maxWidth: 100,
timeMs: 1000,
quality: 10,
);
if (result != null) {
print('β
Thumbnail generated: $result');
} else {
print('β Failed to generate thumbnail');
}
}
2οΈβ£ Generate thumbnail bytes from a video byte array (Web only)
import 'package:video_thumb_kit/video_thumb_kit.dart';
Future<void> main() async {
final videoBytes = Uint8List.fromList([/* video byte array */]);
final result = await VideoThumbKit.thumbnailDataWeb(
videoBytes: videoBytes,
quality: 100,
);
if (result != null) {
print('β
Thumbnail generated: ${result.lengthInBytes} bytes');
} else {
print('β Failed to generate thumbnail');
}
}
π§° API reference
VideoThumbKit.thumbnailFile(...)
Generates a thumbnail from a video file and saves it to disk. Returns the path to the generated file, or null on failure.
| Parameter | Type | Default | Description |
|---|---|---|---|
video |
String |
required | Path to the source video file |
headers |
Map<String, String>? |
null |
Optional headers sent with the request |
thumbnailPath |
String? |
null |
Where to save the thumbnail (auto-generated if omitted) |
imageFormat |
ImageFormat |
ImageFormat.png |
Output image format |
maxHeight |
int |
0 (unbounded) |
Maximum thumbnail height |
maxWidth |
int |
0 (unbounded) |
Maximum thumbnail width |
timeMs |
int |
0 |
Timestamp in the video to capture, in milliseconds |
quality |
int |
10 |
Output image quality |
VideoThumbKit.thumbnailData(...)
Same as above, but returns the thumbnail as a Uint8List instead of writing to disk. Accepts the same parameters (minus thumbnailPath).
VideoThumbKit.thumbnailDataWeb(...)
Generates a thumbnail from a raw video byte array β Web only. Returns a Uint8List, or null on failure.
| Parameter | Type | Default | Description |
|---|---|---|---|
videoBytes |
Uint8List |
required | The source video as a byte array |
quality |
num |
100 |
Output image quality |
πͺ Windows notes
- Thumbnail extraction uses Media Foundation; image encoding uses WIC
ImageFormat.webpcurrently falls back to PNG for compatibility- If
thumbnailPathis omitted, output is written to the OS temp directory
π‘ Example use cases
- ποΈ Thumbnails for video playback screens
- πΌοΈ Building a video gallery grid
- π€ Sharing video previews on social media
See the full example app for a complete, runnable demo.
π€ Contributing
Contributions are welcome! Fork the repository, make your changes, and submit a pull request. π
β Support this project
If video_thumb_kit helped you ship faster, consider starring the repo β it genuinely helps! Found a bug? Open an issue and we'll take a look.