Skip to content

Commit

Permalink
Merge pull request #14 from xaus-group/feature/bitrate
Browse files Browse the repository at this point in the history
Feature/bitrate
  • Loading branch information
husen-hn authored Feb 2, 2025
2 parents caffb2e + 6e2e392 commit 2351f02
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"android":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"ffmpeg_kit_flutter_full_gpl","dependencies":[]}],"date_created":"2024-07-14 19:40:34.620365","version":"3.16.5"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"android":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"ffmpeg_kit_flutter_full_gpl","path":"/home/husen/.puro/shared/pub_cache/hosted/pub.dev/ffmpeg_kit_flutter_full_gpl-6.0.3/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"ffmpeg_kit_flutter_full_gpl","dependencies":[]}],"date_created":"2025-02-01 20:55:00.506270","version":"3.22.3"}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.0
- Added audio bitrate
- Added video bitrate

## 0.2.0
- Added video codecs
- Added audio codecs
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ The `nyx_converter` package in Flutter empowers you to seamlessly convert media
## 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)*
- **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.
- **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)*
- **Bitrate Optimization:** Set the bitrate (in kbps or on Mbps) to strike a balance between quality and file size, catering to different bandwidth requirements or storage constraints.
- **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
Expand Down Expand Up @@ -57,20 +57,26 @@ result = NyxConverter.convertTo(
filePath, // Specify the input file path
outputPath, // Define the output file path
```
**[Container](https://pub.dev/documentation/nyx_converter/latest/nyx_converter/NyxContainer.html):** Choose the desired container for your output media file. [supported containers](https://github.com/xaus-group/nyx_converter/wiki/Container)
**[Container](https://github.com/xaus-group/nyx_converter/wiki/Container):** Choose the desired container for your output media file.

```dart
container: NyxContainer.mp4,
```

**[Video Codec](https://pub.dev/documentation/nyx_converter/latest/nyx_converter/NyxVideoCodec.html):** Select the appropriate video codec for your media file. [supported video codecs](https://github.com/xaus-group/nyx_converter/wiki/Video-codec)
**[Video Codec](https://github.com/xaus-group/nyx_converter/wiki/Video-codec):** Select the appropriate video codec for your media file.
```dart
videoCodec: NyxVideoCodec.h264
videoCodec: NyxVideoCodec.h264,
```

**[Audio Codec](https://pub.dev/documentation/nyx_converter/latest/nyx_converter/NyxAudioCodec.html):** Select the appropriate audio codec for your media file. [supported audio codecs](https://github.com/xaus-group/nyx_converter/wiki/Audio-codec)
**[Audio Codec](https://github.com/xaus-group/nyx_converter/wiki/Audio-codec):** Select the appropriate audio codec for your media file.
```dart
audioCodec: NyxAudioCodec.aac
audioCodec: NyxAudioCodec.aac,
```

**[Bitrate](https://github.com/xaus-group/nyx_converter/wiki/Bitrate):** Set the bitrate to balance between quality and file size. Typical values range from 96 kbps for low quality to 320 kbps for high quality audio, and from 1 Mbps for low quality to 10 Mbps or higher for high quality video.
```dart
audioBitrate: 192,
videoBitrate: 5,
```

**Debug Mode:** Set true for get detailed logs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package io.flutter.plugins;

import io.flutter.plugin.common.PluginRegistry;
import com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FFmpegKitFlutterPlugin.registerWith(registry.registrarFor("com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin"));
}

private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin ffmpeg_kit_flutter_full_gpl, com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin", e);
}
registry.registrarFor(key);
return false;
}
}
2 changes: 1 addition & 1 deletion android/local.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sdk.dir=/opt/android-sdk
flutter.sdk=/home/husen/fvm/versions/3.16.5
flutter.sdk=/home/husen/fvm/versions/3.22.3
2 changes: 1 addition & 1 deletion example/.fvm/flutter_sdk
2 changes: 1 addition & 1 deletion example/.fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.16.5",
"flutterSdkVersion": "3.24.5",
"flavors": {}
}
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ migrate_working_dir/
#.vscode/

# Flutter/Dart/Pub related
/pubspec.lock
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
Expand Down
81 changes: 71 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ class _MyHomePageState extends State<MyHomePage> {
bool isDone = false;
bool isCanceled = false;

final TextEditingController _audioBitrateController = TextEditingController();
final TextEditingController _videoBitrateController = TextEditingController();
String _audioErrorMessage = '';
String _videoErrorMessage = '';
void _parseBitrate() {
setState(() {
_audioErrorMessage = '';
_videoErrorMessage = '';
});

try {
int.parse(_audioBitrateController.text);
} catch (e) {
setState(() {
_audioErrorMessage = 'Please enter a valid integer for bitrate.';
});
}
try {
int.parse(_videoBitrateController.text);
} catch (e) {
setState(() {
_videoErrorMessage = 'Please enter a valid integer for bitrate.';
});
}
}

@override
Widget build(BuildContext context) {
_getPermission();
Expand Down Expand Up @@ -95,12 +121,42 @@ class _MyHomePageState extends State<MyHomePage> {
ACodecDp((codec) {
audioCodec = codec;
}),
// convert to btn
ConvertBtn(
isLoading,
() => _startConvert(inputFilePath, outputPath, container,
videoCodec, audioCodec),
// bitrate text field
TextField(
controller: _audioBitrateController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Enter Audio Bitrate',
errorText:
_audioErrorMessage.isNotEmpty ? _audioErrorMessage : null,
),
),
TextField(
controller: _videoBitrateController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Enter Video Bitrate',
errorText:
_videoErrorMessage.isNotEmpty ? _audioErrorMessage : null,
),
),
// convert to btn
ConvertBtn(isLoading, () {
// check bitrate validation
_parseBitrate();

if (_audioErrorMessage.isEmpty && _videoErrorMessage.isEmpty) {
_startConvert(
inputFilePath,
outputPath,
container,
videoCodec,
audioCodec,
int.parse(_audioBitrateController.text),
int.parse(_videoBitrateController.text),
);
}
}),
// kill btn
KillBtn(
() => NyxConverter.kill(),
Expand Down Expand Up @@ -154,11 +210,14 @@ class _MyHomePageState extends State<MyHomePage> {
}

_startConvert(
String? filePath,
Directory? outputPath,
NyxContainer? container,
NyxVideoCodec? vCodec,
NyxAudioCodec? aCodec) async {
String? filePath,
Directory? outputPath,
NyxContainer? container,
NyxVideoCodec? vCodec,
NyxAudioCodec? aCodec,
int? audioBitrate,
int? videoBitrate,
) async {
setState(() {
isLoading = true;
});
Expand All @@ -178,6 +237,8 @@ class _MyHomePageState extends State<MyHomePage> {
container: container,
videoCodec: vCodec,
audioCodec: aCodec,
audioBitrate: audioBitrate,
videoBitrate: videoBitrate,
fileName: rfilename,
debugMode: true,
execution: (String? path, NyxStatus status, {String? errorMessage}) {
Expand Down
58 changes: 41 additions & 17 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -132,41 +156,41 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.15.0"
nyx_converter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "0.2.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -328,10 +352,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.2"
vector_math:
dependency: transitive
description:
Expand All @@ -340,14 +364,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "14.2.5"
win32:
dependency: transitive
description:
Expand All @@ -365,5 +389,5 @@ packages:
source: hosted
version: "1.0.4"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.5"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
6 changes: 3 additions & 3 deletions ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/home/husen/flutter
FLUTTER_ROOT=/home/husen/fvm/versions/3.22.3
FLUTTER_APPLICATION_PATH=/home/husen/Documents/nyx_converter
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=0.0.1
FLUTTER_BUILD_NUMBER=0.0.1
FLUTTER_BUILD_NAME=0.2.0
FLUTTER_BUILD_NUMBER=0.2.0
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
DART_OBFUSCATION=false
Expand Down
6 changes: 3 additions & 3 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/home/husen/flutter"
export "FLUTTER_ROOT=/home/husen/fvm/versions/3.22.3"
export "FLUTTER_APPLICATION_PATH=/home/husen/Documents/nyx_converter"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=0.0.1"
export "FLUTTER_BUILD_NUMBER=0.0.1"
export "FLUTTER_BUILD_NAME=0.2.0"
export "FLUTTER_BUILD_NUMBER=0.2.0"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
Expand Down
1 change: 0 additions & 1 deletion lib/nyx_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export './src/helper/nyx_container.dart';
export './src/helper/nyx_audio_codec.dart';
export './src/helper/nyx_video_codec.dart';
export './src/helper/nyx_size.dart';
export './src/helper/nyx_bitrate.dart';
export './src/helper/nyx_frequency.dart';
export './src/helper/nyx_channel.dart';
Loading

0 comments on commit 2351f02

Please sign in to comment.