搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.7

export_video_frame

一個用於從影片檔案匯出圖片的 iOS 與 Android 的 Flutter 外掛。

AndroidiOS
近 30 天下載
66
喜歡數
41
Pub 分數
130

安裝套件

flutter pub add export_video_frame

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,讓開發者能在 Android 和 iOS 平台上從影片檔案中擷取靜態影像。它提供簡單的 API,可在特定時間點擷取畫面,適用於產生縮圖或預覽。此插件專為無縫整合至多媒體應用而設計,支援原生影片處理,設定簡單。它利用平台特定功能,確保在各種裝置上實現高效率與相容性。

適用情境

  • 產生影片縮圖
  • 建立預覽影像
  • 提取幀進行分析
  • 建構影片編輯工具
  • 顯示影片快照

主要特色

  • 跨平台支援(iOS 與 Android)
  • 在指定時間戳處提取幀
  • 簡單 API 結合
  • 高性能渲染
  • 原生影片處理

適合對象

  • 影片應用開發者
  • 媒體內容創作者
  • 縮圖生成工具
  • 帶有影片分析的教育應用程式
  • 需要逐幀影片檢視的應用程式

使用建議

  • 需要平台特定權限
  • 僅限影像匯出(無影片編輯)
  • 取決於設備硬體性能
  • 大型影片可能有記憶體限制
  • 未提供內建的 UI 組件

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Export Video frame for Flutter

A Flutter plugin for iOS and Android for exporting picture from video file.

Installation

add export_video_frame as a dependency in your pubspec.yaml file.

Usage


/// Returns whether clean success
  static Future<bool> cleanImageCache() async {
    final String result = await _channel.invokeMethod('cleanImageCache');
    if (result == "success") {
      return true;
    }
    return false;
  }

  /// Save image to album
  ///
  /// - parameters:
  ///    - file: file of video
  ///    - albumName: save the album name
  ///    - waterMark:assetName "images/water_mark.png"
  ///    - alignment: [0,0]represents the center of the rectangle. 
  ///      from -1.0 to +1.0 is the distance from one side of the rectangle to the other side of the rectangle.
  ///      Default value [1,1] repesent right bottom
  ///    - scale: the scale ratio with respect water image size.Default value is 1.0
  /// Returns whether save success
  static Future<bool> saveImage(File file, String albumName,{String waterMark,Alignment alignment,double scale}) async {
    Map<String,dynamic> para = {"filePath":file.path,"albumName":albumName};
    if (waterMark != null) {
      para.addAll({"waterMark":waterMark});
      if (alignment != null) {
        para.addAll({"alignment":{"x":alignment.x,"y":alignment.y}});
      } else {
        para.addAll({"alignment":{"x":1,"y":1}});
      }
      if (scale != null) {
        para.addAll({"scale":scale});
      } else {
        para.addAll({"scale":1.0});
      }
    }
    final bool result =
        await _channel.invokeMethod('saveImage', para);
    return result;
  }

  /// Returns the file list of the exporting image
  ///
  /// - parameters:
  ///    - filePath: file path of video
  ///    - number: export the number of frames
  ///    - quality: scale of export frame."0" is lowest,"1" is origin.("0" is scale for 0.1 in android) 
  static Future<List<File>> exportImage(String filePath, int number,double quality) async {
    var para = {"filePath":filePath,"number":number,"quality":quality};
    final List<dynamic> list =
        await _channel.invokeMethod('exportImage', para);
    var result = list
        .cast<String>()
        .map((path) => File.fromUri(Uri.file(path)))
        .toList();
    return result;
  }

  /// Returns the file list of the exporting image
  ///
  /// - parameters:
  ///    - file: file of video
  ///    - duration: export the duration of frames
  ///    - radian: rotation the frame ,which will export frame.Rotation is clockwise.
  static Future<File> exportImageBySeconds(File file, Duration duration,double radian) async {
    var milli = duration.inMilliseconds;
    var para = {"filePath":file.path,"duration":milli,"radian":radian};
    final String path = await _channel
        .invokeMethod('exportImageBySeconds', para);
    try {
      var result = File.fromUri(Uri.file(path));
      return result;
    } catch (e) {
      throw e;
    }
  }

  /// Returns the file list of the exporting frame for gif file
  ///
  /// - parameters:
  ///    - filePath: file path of video
  ///    - quality: scale of export frame."0" is lowest,"1" is origin.("0" is scale for 0.1 in android) 
  static Future<List<File>> exportGifImage(String filePath, double quality) async {
    var para = {"filePath":filePath,"quality":quality};
    final List<dynamic> list =
        await _channel.invokeMethod('exportGifImagePathList', para);
    var result = list
        .cast<String>()
        .map((path) => File.fromUri(Uri.file(path)))
        .toList();
    return result;
  }

ios

If there will be an error when compile ios app.Because flutter use swift is 4.0. located in ios/Podfile Edit your Podfile as follows:


target 'Runner' do
  use_frameworks! # <--- add this
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['SWIFT_VERSION'] = '4.2' # <--- add this
    end
  end
end

If you use saveAblum api,you need add the add the following keys to your Info.plist file, located ios/Runner/Info.plist:


<key>NSPhotoLibraryUsageDescription</key>
<string>Use Ablum For your purpose</string>

Android

Make sure you add the needed permissions to your Android Manifest Permission.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Example Demo

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。