Flutter Native Video Trimmer

pub package License: MIT

A lightweight Flutter plugin for video manipulation using native code. Trim videos without FFmpeg dependency.

Note: This library focuses specifically on video trimming functionality. If you need more advanced video editing features (trim, merge, crop, rotate, etc.), consider using easy_video_editor.

Why choose this plugin?

  • πŸš€ No FFmpeg Dependency: Uses platform-native video processing capabilities instead of heavy FFmpeg libraries
  • πŸͺΆ Lightweight: Smaller app size and faster processing compared to FFmpeg-based solutions
  • ⚑️ Native Performance: Direct use of Media3 (Android) and AVFoundation (iOS) for optimal performance
  • πŸ“± Memory Efficient: Processes videos without loading entire files into memory
  • πŸ”’ Privacy Focused: All processing happens locally on the device

✨ Features

  • πŸ“Ό Video Loading: Load and process video files from any source
  • βœ‚οΈ Precise Trimming: Trim videos with millisecond precision
  • πŸ› οΈ Native Implementation: Clean and efficient platform-specific code

πŸ“¦ Installation

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

dependencies:
  flutter_native_video_trimmer: ^1.1.8

Or install via command line:

flutter pub add flutter_native_video_trimmer

πŸš€ Usage

Import

import 'package:flutter_native_video_trimmer/flutter_native_video_trimmer.dart';

Initialize

final videoTrimmer = VideoTrimmer();

Load a Video

await videoTrimmer.loadVideo('/path/to/video.mp4');

Trim Video

// Trim the first 5 seconds of the video
final trimmedPath = await videoTrimmer.trimVideo(
  startTimeMs: 0,     // Start time in milliseconds
  endTimeMs: 5000,    // End time in milliseconds (5 seconds)
  includeAudio: true, // Optional, default is true
);

Clear Cache

// Clear the cache
await videoTrimmer.clearCache();

Example

Check the example folder for a complete sample app demonstrating all features.

πŸ“± Platform Support

Platform Implementation Minimum Version Status
Android Media3 API 21 (5.0) βœ…
iOS AVFoundation iOS 11.0 βœ…

πŸ› οΈ Requirements

Android

  • Minimum SDK: API 21 (Android 5.0)
  • Target SDK: API 34
  • Kotlin: 1.9.0
  • AndroidX

iOS

  • Minimum iOS: 11.0
  • Swift: 5.0
  • Xcode: Latest version

🀝 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.