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

パッケージ詳細v1.0.0

native_audio_trimmer

FFmpeg を使用せずに、Android および iOS でオーディオファイルをトリミングするための Flutter プラグインです。

AndroidiOS
30日間ダウンロード
225
いいね数
6
Pub ポイント
150

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

flutter pub add native_audio_trimmer

パッケージ概要

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

NativeAudioTrimmer は、FFmpeg に依存せずに Android および iOS デバイス上でオーディオファイルのトリミングを可能にする Flutter プラグインです。ネイティブプラットフォーム機能を活用して、アプリ内で効率的で軽量なオーディオ処理を提供します。一般的なオーディオ形式をサポートし、必要なセグメントを抽出するための開始時刻と終了時刻を設定する簡単な API を提供します。音声メモのトリミングやポッドキャストのクリッピングなど、基本的なオーディオ編集機能が必要なアプリに最適です。

用途

  • ボイスメモのトリミング
  • 短いオーディオクリップの編集
  • 共有するためのオーディオスニペットを準備する
  • 録音アプリにおけるオーディオ編集の統合
  • カスタムオーディオプレビューの作成

主な機能

  • FFmpeg の依存関係なし
  • クロスプラットフォーム対応(Android および iOS)
  • 開始/終了時刻選択用のシンプルなAPI
  • 軽量で高速な処理
  • ネイティブなオーディオ処理を使用

適している対象

  • オーディオ録音アプリを開発する開発者
  • 基本的なオーディオ編集が必要なアプリ
  • 重い依存関係を避けるプロジェクト
  • 音声メモ機能を備えたモバイルアプリ
  • 教育またはコンテンツ作成ツール

注意事項

  • 基本的なトリミング操作に限定
  • 高度なオーディオ効果をサポートしていません
  • プラットフォーム固有の権限が必要です
  • デバイスによってフォーマットの制限がある可能性があります
  • パフォーマンスはデバイスのハードウェアに依存します

元の README

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

native_audio_trimmer

A Flutter plugin for trimming audio files on both Android and iOS platforms without using FFmpeg. This native audio editor provides powerful audio manipulation capabilities, perfect for Flutter audio trimming in apps, podcast trimming, and voice note editing.

Features

  • Trim audio files by specifying start and end times
  • Native implementation for iOS (using AVAssetExportSession)
  • Native implementation for Android (using MediaExtractor, MediaCodec, and MediaMuxer)
  • No FFmpeg dependency, resulting in smaller app size and faster builds
  • Support for multiple audio formats

Installation

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

dependencies:
  native_audio_trimmer: ^1.0.0
Android

Add the storage permissions to your AndroidManifest.xml if you're targeting Android 12 or below and need to access files outside of your app's directory:

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

For Android 13+ (API level 33+), you may need to request more specific permissions depending on your use case:

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

No additional setup is required for iOS.

Usage

import 'package:native_audio_trimmer/native_audio_trimmer.dart';

// Create an instance of AudioTrimmer
final audioTrimmer = AudioTrimmer();

// Trim an audio file
try {
  String inputPath = '/path/to/input.mp3';
  String outputPath = '/path/to/output.m4a';
  
  // Trim from 10 seconds to 30 seconds
      // Trim audio
      final trimmedFilePath = await NativeAudioTrimmer.trimAudio(
        inputPath: inputPath,
        outputPath: outputPath,
        startTimeInSeconds: 10.0, // Start time in seconds,
        endTimeInSeconds: 30.0, // End time in seconds,
      );
  
  print('Trimmed audio saved at: $trimmedFilePath');
} catch (e) {
  print('Error trimming audio: $e');
}

Example

Check out the example app in the example folder to see a complete implementation of audio file selection, trimming, and playback.

To run the example app:

cd example
flutter run

Implementation Details

iOS

On iOS, this plugin uses the native AVAssetExportSession to perform audio trimming operations. The resulting audio file is saved in the .m4a format.

Android

On Android, the plugin uses a combination of MediaExtractor, MediaCodec, and MediaMuxer to extract, process, and save the audio data between the specified start and end times.

Supported Formats

Input Formats
  • MP3
  • M4A/AAC
  • WAV
  • OGG (Android only)
  • FLAC
Output Format
  • M4A (AAC) for both platforms

Limitations

  • The plugin currently only outputs to M4A format
  • Very large audio files may require additional memory
  • Some exotic audio formats might not be supported by the native APIs

Contributing

Contributions are welcome! If you find a bug or want a feature, please open an issue on GitHub.

License

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

カテゴリー

ソースリポジトリ

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

データはまだありません。