Coder Social home page Coder Social logo

xaus-group / nyx_converter Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 1.61 MB

A Flutter package that makes it easier to convert formats, codecs, etc. of media files.

Home Page: https://pub.dev/packages/nyx_converter

License: GNU Lesser General Public License v3.0

Dart 92.16% Java 1.29% Kotlin 0.21% Swift 2.93% Objective-C 1.62% Shell 1.79%
audio audio-codec audio-converter codec converter dart ffmpeg flutter format video

nyx_converter's Introduction

Nyx Converter Github release pub package License Github Stars Issues

nyx_converter logo

The nyx_converter package in Flutter empowers you to seamlessly convert media files between various formats, codecs, resolutions, bitrates, and audio properties. It utilizes the robust ffmpeg under the hood, providing a convenient and efficient solution for your media processing needs within your Flutter applications.

Key Features

  • Extensive Container Support: Convert a wide range of video and audio file containers.
  • Flexible Codec Control: Specify desired video codecs (e.g., H.264, VP8) and audio codecs (e.g., AAC, MP3) to tailor the output file's characteristics. (will be added)
  • Granular Resolution Management: Define the exact width and height in pixels for the converted video, granting precise control over the output dimensions. (will be added)
  • Bitrate Optimization: Set the bitrate (in kbps) to strike a balance between quality and file size, catering to different bandwidth requirements or storage constraints. (will be added)
  • Audio Fine-Tuning: Specify the sampling frequency (in Hz) and number of channels (mono or stereo) for the audio stream within the converted media file, allowing for customized audio output. (will be added)

Installation

To use this package, add nyx_converter as a dependency in your pubspec.yaml file.

dependencies:
  nyx_converter: <latest-version>

Platform Support

The following table shows Android API level, iOS deployment target and macOS deployment target requirements in nyx_converter releases.

Android
API Level
iOS Minimum
Deployment Target
macOS Minimum
Deployment Target
24 12.1 10.15

Using

Import: Import the package in your Dart code:

import 'package:nyx_converter/nyx_converter.dart';

Widget Usage: Use .convertTo method for initiate the media file path and desired output file path to save converted media file.

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  filePath, // Specify the input file path
  outputPath, // Define the output file path

Container: Choose the desired container for your output media file.

Video Audio
AVI WAV
MP4 FLAC
MKV OGG
MOV AAC
WebM MP3
  container: NyxContainer.mp4,

Debug Mode: Set true for get detailed logs

  debugMode: true,

Output file name: Set output file name

  fileName: 'new_name',

Execution: execution callback provides the path of the converted file and the status and messages of the conversion process.

  execution: (String? path, NyxStatus status, {String? errorMessage}) {
    //TODO: codes
  }
);

Stop process: Use .kill method to kill all nyx_converter processes.

NyxConverter.kill();

Contributing

There is not much to contribute since the package serves its purpose, however, in chance of needing to bump or adjust some version, or any other suggestion for that matter, please read CONTRIBUTING.

nyx_converter's People

Contributors

husen-hn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

denghuafeng

nyx_converter's Issues

Does not build on Android (Execution failed for task ':app:stripDebugDebugSymbols'.)

I tried to add the package to my Flutter app, to only use it on iOS to convert OGG files to something that can be played there. But now on Android the build fails with this output:

WARNING: [Processor] Library '/home/runner/.gradle/caches/modules-2/files-2.1/androidx.media2/media2-session/1.2.1/f927563711e36371c19b2e86fb7ccf1c3f259ca4/media2-session-1.2.1.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
 Example of androidX reference: 'androidx/media2/session/MediaBrowser$Builder'
 Example of support library reference: 'android/support/v4/media/session/MediaSessionCompat$Token'

[...]

Note: Recompile with -Xlint:deprecation for details.
/usr/local/lib/android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/runner/work/fluffychat/fluffychat/build/app/intermediates/merged_native_libs/debug/out/lib/x86_64/libflutter.so': '/home/runner/work/fluffychat/fluffychat/build/app/intermediates/stripped_native_libs/debug/out/lib/x86_64/libflutter.so': No space left on device
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> There was a failure while executing work items
   > A failure occurred while executing com.android.build.gradle.internal.tasks.StripDebugSymbolsRunnable
      > /home/runner/work/fluffychat/fluffychat/build/app/intermediates/merged_native_libs/debug/out/lib/x86_64/libflutter.so -> /home/runner/work/fluffychat/fluffychat/build/app/intermediates/stripped_native_libs/debug/out/lib/x86_64/libflutter.so: No space left on device
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org/
BUILD FAILED in 7m 11s
Running Gradle task 'assembleDebug'...                            432.3s
Gradle task assembleDebug failed with exit code 1
Error: Process completed with exit code 1.

So the problem seems to be that there is "no space left on device"? When I remove the package, the problem is solved. Does this package somehow need a lot of space when compiling on Android? This logs are from Github actions where I use the default VMs so I don't have much flexibility to increase the space...

I tried:

  • set minSdkVersion from 21->24.
  • Add ext.flutterFFmpegPackage = 'audio-lts' to build.gradle
  • Add tools:overrideLibrary="com.arthenica.ffmpegkit.flutter to the manifest file

Flutter doctor -v output:

[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale de-DE)
    • Flutter version 3.22.3 on channel stable at /Users/christianpauly/develop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (vor 3 Wochen), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4)
    • Android SDK at /Users/christianpauly/Library/Android/sdk
    • Platform android-34, build-tools 35.0.0-rc4
    • ANDROID_HOME = /Users/christianpauly/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.91.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (5 available)
    • iPhone (mobile)                 • 00008030-001E11C12683802E • ios            • iOS 17.6 21G80
    • Kußowski iPad (mobile)          • 00008101-000215D40A99001E • ios            • iOS 17.6 21G80
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79
      darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79
      darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome
      127.0.6533.89

[✓] Network resources
    • All expected network resources are available.

• No issues found!

videoCodec

Add video codec functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  videoCodec: NyxVideoCodec.h264, // Specify the video codec (optional)l)
);

kill

Add kill all process functionality

NyxConverter.kill(); // kill all process of NyxConverter widget

Execution

Add Execution callback functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
    execution: (String? path, NyxStatus status, int percent,{String? errorMessage}) {
    //TODO: codes
  }
);

size

Add video size functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  size: NyxSize.w1280h720, // Set the width and height in pixels (optional)
);

Container

Add container functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
    container: NyxContainer.mp4
);

audioCodec

Add audio codec functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  audioCodec: NyxAudioCodec.flac, // Define the audio codec (optional)
);

debugMode

Add debug mode functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
      debugMode: true
);

channelLayout

Add audio channel layout functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  channelLayout: NyxChannelLayout.stereo // Define the number of channels (optional)
);

fileName

Add output file name functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
    fileName: 'new_name'
);

frequency

Add audio frequency functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  frequency: NyxFrequency.hz48000, // Specify the sampling frequency in Hz (optional)
);

subscribe

Add subscribe functionality for receive percent, time, and isDone values.

NyxCoverter.convertTo$.subscribe((int percent, int time, bool isDone) {
      printDebug('percent on complition $percent');
      printDebug('time of file process $time');
      printDebug('process is done $isDone');
});

help1 help2

bitrate

Add audio bitrate functionality

final filePath = 'path/to/my.mp4';
final outputPath = 'path/to/';
result =  NyxConverter.convertTo(
  bitrate: NyxBitrate.k320, // Set the bitrate in kbps (optional)
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.