import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';
import 'package:ffmpeg_kit_flutter/return_code.dart';
/// 透過 FFmpeg 後處理對聲音進行降噪音
/// 使用內建的 afftdn (目前版本無法附加額外參數)
Future<void> audioNoiseCanceling(String inputFilePath, String outputFilePath)async {
// FFmpeg command to remove noise using the 'afftdn' filter
String command = '-i $inputFilePath -af afftdn $outputFilePath';
// 檢查檔案是否已經存在,若存在則刪除
final outputFile = File(outputFilePath);
if (await outputFile.exists()) {
try {
await outputFile.delete();
print('Existing file deleted: $outputFilePath');
} catch (e) {
print('Failed to delete existing file: $e');
}
}

Leave a comment