Reputation: 51
Audio Trim is not working
Flutter Version : 3.0.2 Dart : 2.17.3
Package used : ffmpeg_kit_flutter: ^4.5.1
Input file path : "/data/user/0/com.goonetech.v1.gofinal/cache/file_picker/sample-15s.mp3"
Output file path : "/data/user/0/com.goonetech.v1.gofinal/app_flutter/output.mp3"
double start=2,
double end=5;
String path="/data/user/0/com.goonetech.v1.gofinal/cache/file_picker/sample-15s.mp3"
static Future<String> cutAudio(String path, double start, double end) async {
final Directory dir = await getApplicationDocumentsDirectory();
final outPath = "${dir.path}/output.mp3";
double start = 1;
double end = 5;
try
{
await File(outPath).delete();
} catch (e) {
print("Delete Error");
}
var cmd =
"-y -i \"$path\" -vn -ss $start -to $end -ar 16k -ac 2 -b:a 96k -acodec libmp3lame $outPath";
FFmpegKit.executeAsync(cmd, (session) async {
final returnCode = await session.getReturnCode();
print("returnCode $returnCode");
});
return outPath;
}
The output is : returnCode 1
The output path does not have the file (File not found exception)
Upvotes: 1
Views: 960
Reputation: 17802
You have to enable lame for this to work. By default FFmpegKit comes with html package. To use lame you have to use audio library
In android/build.gradle add the ext
ext {
flutterFFmpegPackage = "audio"
}
Check this for more info https://pub.dev/documentation/flutter_ffmpeg/latest/
Upvotes: 1