我正在尝试在基于 flutter 的应用程序中使用 ffmpeg 将视频转换为音频,但命令不起作用。
命令有问题吗?
void convert(File pickedVideo) async {
Directory applicationDocDirectory = await getApplicationDocumentsDirectory();
final outputPath = '${applicationDocDirectory.path}/output-audio-${const Uuid().v1()}.mp3';
final session = await FFmpegKit.execute('-i ${pickedVideo.path} -vn -acodec mp3 $outputPath');
final returnCode = await session.getReturnCode();
print(ReturnCode.isSuccess(returnCode)); // return false
}
您可以尝试拆分会话参数。
final session = await FFmpegKit.execute(['-i', pickedVideo.path, '-vn', '-acodec', 'mp3', outputPath]);
你的代码看起来像这样
void convert(File pickedVideo) async {
Directory applicationDocDirectory = await getApplicationDocumentsDirectory();
final outputPath = '${applicationDocDirectory.path}/output-audio-${const Uuid().v1()}.mp3';
final session = await FFmpegKit.execute(['-i', pickedVideo.path, '-vn', '-acodec', 'mp3', outputPath]);
final returnCode = await session.getReturnCode();
print(ReturnCode.isSuccess(returnCode)); // return false
}