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

套件詳情v0.1.7

easy_video_editor

一個輕量級的 Flutter 插件,無需 FFmpeg 依賴即可進行影片編輯。可在 Android 與 iOS 上執行剪輯、合併、調整速度等操作。

AndroidiOS
近 30 天下載
1.2萬
喜歡數
53
Pub 分數
160

安裝套件

flutter pub add easy_video_editor

套件介紹

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

Easy Video Editor 是一個輕量級的 Flutter 外掛程式,可在 Android 和 iOS 上直接進行基本影片編輯,無需依賴 FFmpeg。它允許使用者裁切、合併和調整影片播放速度,設定簡單。設計簡潔且效能出色,可無縫整合至 Flutter 應用中,非常適合需要快速影片處理的應用程式。該外掛程式高效處理媒體,相比重型相依項目,顯著減小了應用體積與複雜度。

適用情境

  • 剪輯影片片段
  • 合併多個影片
  • 調整播放速度
  • 創建短影片內容
  • 行動應用中的簡單影片處理

主要特色

  • 無 FFmpeg 依賴
  • 跨平台支援(Android 與 iOS)
  • 輕便且快速
  • 用於常見編輯的簡單 API
  • 內建影片壓縮

適合對象

  • 開發以影片為中心的應用程式之開發者
  • 需要基本影片編輯的應用
  • 專案避免使用大型相依性
  • 以行動裝置為優先的影片工具
  • 教育類或社交媒體應用

使用建議

  • 僅限基本編輯功能
  • 無高級效果或濾鏡
  • 依賴於平台特定的媒體 API
  • 在不同裝置上效能可能有所差異
  • 不適合專業影片編輯

原始 README

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

Easy Video Editor

A powerful Flutter plugin for video editing operations with a simple, chainable API - without FFmpeg dependency. Perform common video editing tasks like trimming, merging, speed adjustment, and more with ease by leveraging native platform capabilities.

pub package likes License: MIT

Features

  • 🎬 Video Trimming: Cut videos at specified start and end times
  • 🔄 Video Merging: Combine multiple videos into one
  • ⚡ Speed Adjustment: Change video playback speed
  • 🔊 Audio Operations:
    • Extract audio from video
    • Remove audio from video
  • 📐 Video Transformations:
    • Scale video to specific dimensions
    • Rotate video by specified degrees
    • Crop video to specific aspect ratios
    • Flip video horizontally or vertically
  • 🗜️ Video Compression:
    • Compress videos to standard resolutions (360p to 4K)
    • Maintains aspect ratio while resizing
  • 🖼️ Thumbnail Generation: Create thumbnails from video frames
  • 🧩 Raw Frame Extraction: Read RGBA8888 pixels from a video frame
  • 📊 Video Metadata: Retrieve detailed information about video files
  • 🔗 Builder Pattern API: Chain operations for complex video editing
  • 📱 Platform Support: Works on both Android and iOS
  • 📦 iOS Package Managers: Supports both CocoaPods and Swift Package Manager

Installation

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

dependencies:
  easy_video_editor: ^0.1.6

Or install via command line:

flutter pub add easy_video_editor

Usage

Basic Example
import 'package:easy_video_editor/easy_video_editor.dart';

// Create a builder instance
final editor = VideoEditorBuilder(videoPath: '/path/to/video.mp4')
  .trim(startTimeMs: 0, endTimeMs: 5000)  // Trim first 5 seconds
  .speed(speed: 1.5)     // Speed up by 1.5x
  .removeAudio(); // Remove audio

// Export the edited video with progress tracking
final outputPath = await editor.export(
  outputPath: '/path/to/output.mp4', // Optional output path
  onProgress: (progress) {
    // Progress ranges from 0.0 to 1.0 (0% to 100%)
    print('Export progress: ${(progress * 100).toStringAsFixed(1)}%');
    // Update UI with progress information
    // e.g., setState(() => exportProgress = progress);
  }
);
Advanced Example
final editor = VideoEditorBuilder(videoPath: '/path/to/video.mp4')
  // Trim video
  .trim(startTimeMs: 1000, endTimeMs: 6000)

  // Merge with another video
  .merge(otherVideoPaths: ['/path/to/second.mp4'])

  // Adjust speed
  .speed(speed: 1.5)

  // Compress video
  .compress(resolution: VideoResolution.p720)

  // Crop video
  .crop(aspectRatio: VideoAspectRatio.ratio16x9)

  // Rotate video
  .rotate(degree: RotationDegree.d90)

  // Flip video
  .flip(flipDirection: FlipDirection.horizontal);

// Export the final video
final outputPath = await editor.export(
  outputPath: '/path/to/output.mp4' // Optional output path
);

// Extract audio
final audioPath = await editor.extractAudio(
  outputPath: '/path/to/output.m4a' // Optional output path, iOS outputs M4A format
);

// Generate thumbnail
final thumbnailPath = await editor.generateThumbnail(
  positionMs: 2000,
  quality: 85,
  width: 1280,    // optional
  height: 720,    // optional
  exactFrame: true, // optional, request exact-frame extraction when supported
  outputPath: '/path/to/thumbnail.jpg' // Optional output path
);

// Extract raw RGBA8888 frame pixels
final frame = await editor.getFrame(
  positionMs: 2000,
  width: 320, // optional
  height: 180, // optional
  exactFrame: true, // optional, request closest exact frame when supported
);

if (frame != null) {
  print('Frame: ${frame.width}x${frame.height}');
  print('Pixel bytes: ${frame.bytes.length}');
}

// Get video metadata
final metadata = await editor.getVideoMetadata();
print('Duration: ${metadata.duration} ms');
print('Dimensions: ${metadata.width}x${metadata.height}');
print('Orientation: ${metadata.rotation}°');
print('File size: ${metadata.fileSize} bytes');
print('Creation date: ${metadata.date}');
Progress Tracking
final editor = VideoEditorBuilder(videoPath: '/path/to/video.mp4')
  .trim(startTimeMs: 1000, endTimeMs: 10000)
  .compress(resolution: VideoResolution.p720);

// Track export progress
double exportProgress = 0.0;

// Export with progress updates
final outputPath = await editor.export(
  outputPath: '/path/to/output.mp4',
  onProgress: (progress) {
    setState(() {
      exportProgress = progress; // Update state variable
    });

    // Use progress value (0.0 to 1.0) to update UI
    // For example, with a LinearProgressIndicator:
    // LinearProgressIndicator(value: exportProgress)
  }
);
Cancel Operation
final editor = VideoEditorBuilder(videoPath: '/path/to/video.mp4');

// Start an operation
final outputPath = await editor.trim(startTimeMs: 0, endTimeMs: 5000);

// Cancel the operation
await editor.cancel();

API Reference

VideoEditorBuilder

The main class for chaining video operations.

Constructor
  • VideoEditorBuilder({required String videoPath}): Creates a new builder instance
Methods
  • trim({required int startTimeMs, required int endTimeMs}): Trim video to specified duration (outputs MP4)
  • merge({required List<String> otherVideoPaths}): Merge with other videos, fitting mixed dimensions and orientations into one output canvas (outputs MP4)
  • speed({required double speed}): Adjust playback speed (e.g., 0.5 for half speed, 2.0 for double speed) (outputs MP4)
  • removeAudio(): Remove audio track (outputs MP4)
  • rotate({required RotationDegree degree}): Rotate video by 90, 180, or 270 degrees (outputs MP4)
  • crop({required VideoAspectRatio aspectRatio}): Crop video to predefined aspect ratio (outputs MP4)
  • compress({VideoResolution resolution = VideoResolution.p720}): Compress video to standard resolution (outputs MP4)
    • Available resolutions: 360p, 480p, 720p, 1080p, 2160p (4K)
    • Maintains original aspect ratio
  • flip({required FlipDirection flipDirection}): Flip video horizontally or vertically (outputs MP4)
  • export({String? outputPath, void Function(double progress)? onProgress}): Process all operations and return output path (outputs MP4)
    • outputPath: Optional custom path for the output file
    • onProgress: Optional callback that receives progress updates (0.0 to 1.0) during export
  • extractAudio({String? outputPath}): Extract audio to separate file (outputs M4A on iOS, AAC on Android)
  • generateThumbnail({required int positionMs, required int quality, int? width, int? height, bool exactFrame = false, String? outputPath}): Generate thumbnail (outputs JPEG)
  • getFrame({required int positionMs, int? width, int? height, bool exactFrame = false}): Extract raw RGBA8888 frame pixels at the requested video position
  • getVideoMetadata(): Retrieves detailed metadata about the current video file
  • get currentPath: Gets the current video path

Platform Specific Setup

Android

Add the following permissions to your AndroidManifest.xml:

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

Requires iOS 13.0 or later.

The iOS plugin supports both CocoaPods and Swift Package Manager. Flutter will use Swift Package Manager when it is enabled in your Flutter project and will continue to fall back to CocoaPods for existing projects.

On iOS, transformed video exports such as merge, scale, rotate, flip, and crop preserve the source track frame rate when AVFoundation reports one. If the source frame rate is unavailable, the exporter falls back to 30 fps.

Add the following keys to your Info.plist:

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library for video editing.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app requires access to the photo library to save edited videos.</string>

🤝 Contributing

Contributions are always welcome! Here's how you can help:

  1. 🐛 Report bugs by opening an issue
  2. 💡 Suggest new features or improvements
  3. 📝 Improve documentation
  4. 🔧 Submit pull requests

License

This project is licensed under the MIT License - see the LICENSE file for details.

📧 Author

iawtk2302

⭐ Show Your Support

If you find this plugin helpful, please give it a star on GitHub! It helps others discover the plugin and motivates me to keep improving it.

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。