パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.7.3

get_thumbnail_video

ローカルの動画ファイルまたは動画URLからサムネイルを作成するためのFlutterプラグインです。

AndroidiOSWeb
30日間ダウンロード
9.8万
いいね数
63
Pub ポイント
130

パッケージをインストール

flutter pub add get_thumbnail_video

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

ローカルの動画ファイルまたは動画URLからサムネイル画像を生成するFlutterプラグインです。Android、iOS、Webプラットフォームをサポートしており、開発者が動画から代表的なフレームを抽出してプレビュー、ギャラリー、メディア表示に活用できるようにしています。プラグインは、プラットフォーム固有の実装を通じてネイティブ機能を利用し、デバイス間での効率的なパフォーマンスと互換性を確保します。フル動画を再生せずに動画コンテンツの視覚的表現が必要なアプリケーションにおいて特に有用です。

用途

  • 動画プレビューの生成
  • メディアギャラリーのサムネイル
  • コンテンツ推薦のUI
  • 動画アップロードのプレビュー
  • ソーシャルメディア投稿のプレビュー

主な機能

  • ローカル動画ファイルをサポートしています
  • 動画URLをサポートしています
  • クロスプラットフォーム(Android、iOS、Web)
  • 効率的なフレーム抽出
  • シンプルなAPI統合

適している対象

  • メディア重視のアプリケーション
  • 動画共有プラットフォーム
  • コンテンツマネジメントシステム
  • 動画ライブラリを備えたモバイルアプリ
  • ウェブベースのビデオビューア

注意事項

  • Android および iOS で適切な権限が必要です
  • Webのサポートには、ブラウザの機能によって制限が生じる可能性があります
  • 大きな動画ファイルはパフォーマンスに影響を与える可能性があります
  • サムネイルの品質は、元の動画の解像度に依存します
  • リモートURLに対するネットワークリクエストにはエラー処理が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

get_video_thumbnail

This project is a modified fork of video_thumbnail, originally created by John Zhong. Modifications and improvements have been made to adapt the project to new needs.

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 / Android / web.

pub ver license

video-file video-url

Methods

function parameter description return
thumbnailData String [video], optional Map<String, dynamic> [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<Uint8List>]
thumbnailFile String [video], optional Map<String, dynamic> [headers], String [thumbnailPath](folder or full path where to store the thumbnail file, null to save to same folder as the video file) this ignored on the web, 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. To generate the thumbnail from a network resource, the video must be properly URL encoded.

Usage

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

dependencies:
  get_thumbnail_video: ^0.7.3

import

import 'package:get_thumbnail_video/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

XFile thumbnailFile = 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,
);

final image = kIsWeb ? Image.network(thumbnailFile.path) : Image.file(File(thumbnailFile.path));

Generate a thumbnail file from video Assets declared in pubspec.yaml

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,
);

Limitations on the Web platform

Flutter Thumbnail on the Web platform has some limitations that might surprise developers more familiar with mobile/desktop targets.

In no particular order:

CORS headers

This plugin requires the server hosting the video to include appropriate CORS headers in the response. Specifically, the server must include the Access-Control-Allow-Origin and Access-Control-Allow-Methods headers in the response to the request. For more information, please refer to the Mozilla Developer Network documentation.

HTTP range headers

This plugin requires the server hosting the video to support HTTP range headers. If the server does not support range requests, the plugin may generate a thumbnail from the first frame of the video instead of the desired frame. For more information, please refer to the Mozilla Developer Network documentation.

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.

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

ランキング