音频修剪不起作用
颤振版本:3.0.2 飞镖:2.17.3
使用的封装: ffmpeg_kit_flutter:^4.5.1
输入文件路径: “/data/user/0/com.goonetech.v1.gofinal/cache/file_picker/sample-15s.mp3”
输出文件路径: “/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;
}
输出为: 返回码1
输出路径没有该文件(文件未找到异常)
您必须启用 lame 才能正常工作。默认情况下 FFmpegKit 附带 html 包。要使用lame你必须使用音频库
在 android/build.gradle 添加 ext
ext {
flutterFFmpegPackage = "audio"
}
新方法是:
ffmpeg_kit_flutter_audio: ^6.0.3