attention!!!
1.iOS中必须设置iOS支持最小12.1--我直接设置为13.0
2.安卓必须最小支持24版本
3.需求:将后台url链接下周到本地file文件中(后台给我的是amr:微信语音格式)
4.iOS和安卓不能直接播放amr,需要转码,iOS有一个比较好用的音频转码:VoiceConvert 无奈写插件过程中遇阻,考虑到iOS和安卓都需要使用:ffmpeg_kit_flutter 闪亮登场!!!
5.主要是通过不同的指令处理不同的事情查阅资料
https://blog.csdn.net/Daibvly/article/details/121487204
https://www.freesion.com/article/69731337562/
最终参考了一些指令执行代码如下实现的音频格式转换
await FFmpegKit.execute('-i ${getRecordModel?.data?[index].filePath} ${getRecordModel?.data?[index].filePath?.replaceAll("amr", "wav")}').then((session) async {
final returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
print("FFmpegKit SUCCESS");
await player.setFilePath((getRecordModel?.data?[index].filePath?.replaceAll("amr", "wav"))!);
player.play();
} else if (ReturnCode.isCancel(returnCode)) {
print("FFmpegKit CANCEL");
} else {
print("FFmpegKit 错误");
// ERROR
}
// Unique session id created for this execution
final sessionId = session.getSessionId();
final command = session.getCommand();
print("我的指令${command}");
final commandArguments = session.getArguments();
// State of the execution. Shows whether it is still running or completed
final state = await session.getState();
final startTime = session.getStartTime();
final endTime = await session.getEndTime();
final duration = await session.getDuration();
// Console output generated for this execution
final output = await session.getOutput();
// The stack trace if FFmpegKit fails to run a command
final failStackTrace = await session.getFailStackTrace();
// The list of logs generated for this execution
final logs = await session.getLogs();
// The list of statistics generated for this execution (only available on FFmpegSession)
// final statistics = await (session as FFmpegSession).getStatistics();
});
6.print("FFmpegKit 错误"); 重复转同一个输出路径的时候会报错(可能是文件路径已经存在)
7.未完持续带更新中