video_thumbnail 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

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 license

video-file video-url

Methods #

functionparameterdescriptionreturn
thumbnailDataString [video], 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<Uint8List>]
thumbnailFileString [video], 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<String>]

Warning:

Giving both the maxHeight and maxWidth has different result on Android platform, it actually scales the thumbnail to the specified maxHeight and maxWidth.

Usage #

Installing add video_thumbnail as a dependency in your pubspec.yaml file.

dependencies:
  video_thumbnail: ^0.2.0

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 uint8list = 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 #

Fork or pull requests are always welcome. Currently it seems have a little performance issue while generating WebP thumbnail by using libwebp under iOS.

0.2.0 #

  • Breaking change: Switch the maxHeightOrWidth to maxHeight and maxWidth

0.1.7 #

  • Generate the thumbnail asynchronously on Android. ( Thanks for Tairs Rzajevs )

0.1.6 #

  • Add timeMs, use getScaledFrameAtTime to eliminate image scaling if Android API level >= 27

0.1.5+1 #

  • Minor updates

0.1.5 #

  • Add repository and issue tracker link and bump version to 0.1.5

0.1.3+5 #

  • Fix compiler warning

0.1.3+4 #

  • Fix "src/dsp/dsp.h" couldn't find issue due to Podfile has "use_frameworks!"

0.1.3+3 #

  • Fix the screen shots url issue

0.1.3+2 #

  • Add some screen shots

0.1.3 #

  • Bump the version

0.0.3 #

  • Add test case

0.0.2 #

  • Add webp support for iOS

0.0.1 #

  • initial release for this flutter plugin.

example/README.md

video_thumbnail_example #

Demonstrates how to use the video_thumbnail plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  video_thumbnail: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:video_thumbnail/video_thumbnail.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/video_thumbnail.dart.

Run flutter format to format lib/video_thumbnail.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test