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.
methods
function | parameter | description | return |
---|---|---|---|
thumbnaildata | string
, imageformat
|
||
thumbnailfile | string
, string |
creates a file of the thumbnail from the
|
[future<string>] |
warning:
giving both the
maxheight
andmaxwidth
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, thevideo
must be properly url encoded.
usage
installing
add video_thumbnail as a dependency in your pubspec.yaml file.
dependencies:
video_thumbnail: ^0.3.1
import
import 'package:video_thumbnail/video_thumbnail.dart';
generate a thumbnail in memory from video file
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
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,
);
notes
download or pull requests are always welcome. currently it seems have a little performance issue while generating webp thumbnail by using libwebp under ios.
Comments are closed.