# fluttertpc_video_thumbnail **Repository Path**: openharmony-sig/fluttertpc_video_thumbnail ## Basic Information - **Project Name**: fluttertpc_video_thumbnail - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2024-11-11 - **Last Updated**: 2025-08-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [fluttertpc_video_thumbnail](https://gitcode.com/openharmony-sig/fluttertpc_video_thumbnail)。| ⚠️ This repository has been archived. For the new address, please visit [fluttertpc_video_thumbnail](https://gitcode.com/openharmony-sig/fluttertpc_video_thumbnail).** > --- > # video_thumbnail This plugin generates thumbnail from video file or URL. It returns image in memory or writes into a file. It offers rich options to control the image format, resolution and quality. Supports iOS and Android. [![pub ver](https://img.shields.io/badge/pub-v0.5.3-blue)](https://pub.dev/packages/video_thumbnail) [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/justsoft/) ![video-file](https://github.com/justsoft/video_thumbnail/blob/master/video_file.png?raw=true) ![video-url](https://github.com/justsoft/video_thumbnail/blob/master/video_url.png?raw=true) ## Methods |function|parameter|description|return| |--|--|--|--| |thumbnailData|String `[video]`, optional Map `[headers]`, ImageFormat `[imageFormat]`(JPEG/PNG/WEBP), int `[maxHeight]`(0: for the original resolution of the video, or scaled by the source aspect ratio), [maxWidth]`(0: for the original resolution of the video, or scaled by the source aspect ratio), int `[timeMs]` generates the thumbnail from the frame around the specified millisecond, int `[quality]`(0-100)|generates thumbnail from `[video]`|`[Future]`| |thumbnailFile|String `[video]`, optional Map `[headers]`, String `[thumbnailPath]`(folder or full path where to store the thumbnail file, null to save to same folder as the video file), ImageFormat `[imageFormat]`(JPEG/PNG/WEBP), int `[maxHeight]`(0: for the original resolution of the video, or scaled by the source aspect ratio), int `[maxWidth]`(0: for the original resolution of the video, or scaled by the source aspect ratio), int `[timeMs]` generates the thumbnail from the frame around the specified millisecond, int `[quality]`(0-100)|creates a file of the thumbnail from the `[video]` |`[Future]`| Warning: > Giving both the `maxHeight` and `maxWidth` has different result on Android platform, it actually scales the thumbnail to the specified maxHeight and maxWidth. > To generate the thumbnail from a network resource, the `video` must be properly URL encoded. ## Usage **Installing** add [video_thumbnail](https://pub.dev/packages/video_thumbnail) as a dependency in your pubspec.yaml file. ```yaml dependencies: video_thumbnail: ^0.5.3 ``` **import** ```dart import 'package:video_thumbnail/video_thumbnail.dart'; ``` **Generate a thumbnail in memory from video file** ```dart final uint8list = await VideoThumbnail.thumbnailData( video: videofile.path, imageFormat: ImageFormat.JPEG, maxWidth: 128, // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio quality: 25, ); ``` **Generate a thumbnail file from video URL** ```dart final fileName = await VideoThumbnail.thumbnailFile( video: "https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4", thumbnailPath: (await getTemporaryDirectory()).path, imageFormat: ImageFormat.WEBP, maxHeight: 64, // specify the height of the thumbnail, let the width auto-scaled to keep the source aspect ratio quality: 75, ); ``` **Generate a thumbnail file from video Assets declared in pubspec.yaml** ```dart final byteData = await rootBundle.load("assets/my_video.mp4"); Directory tempDir = await getTemporaryDirectory(); File tempVideo = File("${tempDir.path}/assets/my_video.mp4") ..createSync(recursive: true) ..writeAsBytesSync(byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes)); final fileName = await VideoThumbnail.thumbnailFile( video: tempVideo.path, thumbnailPath: (await getTemporaryDirectory()).path, imageFormat: ImageFormat.PNG, quality: 100, ); ``` ## Notes Fork or pull requests are always welcome. Currently it seems have a little performance issue while generating WebP thumbnail by using libwebp under iOS.