attentionH怕贰!小作!
1.iOS中必須設(shè)置iOS支持最小12.1--我直接設(shè)置為13.0
2.安卓必須最小支持24版本
3.需求:將后臺(tái)url鏈接下周到本地file文件中(后臺(tái)給我的是amr:微信語(yǔ)音格式)
4.iOS和安卓不能直接播放amr恒序,需要轉(zhuǎn)碼三圆,iOS有一個(gè)比較好用的音頻轉(zhuǎn)碼:VoiceConvert 無(wú)奈寫插件過(guò)程中遇阻悬嗓,考慮到iOS和安卓都需要使用:ffmpeg_kit_flutter 閃亮登場(chǎng)N酆簟!包竹!
5.主要是通過(guò)不同的指令處理不同的事情查閱資料
https://blog.csdn.net/Daibvly/article/details/121487204
https://www.freesion.com/article/69731337562/
最終參考了一些指令執(zhí)行代碼如下實(shí)現(xiàn)的音頻格式轉(zhuǎn)換
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 錯(cuò)誤");
// 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 錯(cuò)誤"); 重復(fù)轉(zhuǎn)同一個(gè)輸出路徑的時(shí)候會(huì)報(bào)錯(cuò)(可能是文件路徑已經(jīng)存在)
7.未完持續(xù)帶更新中