Open KY-Jung opened 9 months ago
Hey I found out that this issue is comming from using a file that is not mp3.
For mobile update Save function inside Trimmer class to this:
Future
String command = '';
String outputPath;
String formattedDateTime = DateTime.now().millisecondsSinceEpoch.toString();
debugPrint("Formatted: $formattedDateTime");
audioFolderName ??= "Trimmer";
audioFileName ??= "${audioName}_trimmed_$formattedDateTime";
audioFileName = audioFileName.replaceAll(' ', '_');
String path = await _createFolderInAppDocDir(
audioFolderName,
storageDir,
).whenComplete(
() => debugPrint("Retrieved Trimmer folder"),
);
Duration startPoint = Duration(milliseconds: startValue.toInt());
Duration endPoint = Duration(milliseconds: endValue.toInt());
debugPrint("Start: ${startPoint.toString()} & End: ${endPoint.toString()}");
debugPrint(path);
String trimLengthCommand =
' -ss ${startPoint.inSeconds} -i "$audioPath" -t ${(endPoint - startPoint).inSeconds}';
command = '$trimLengthCommand ';
// outputPath = '$path$audioFileName.$outputFormatString';
outputPath = '$path$audioFileName.aac';
command += ' -c:a aac "$outputPath"';
// command = "ffmpeg -i $audioPath -ss 60 -to 70 $outputPath";
// Additional debug information
debugPrint("Executing FFmpeg command: $command");
FFmpegKit.executeAsync(command, (session) async {
final state =
FFmpegKitConfig.sessionStateToString(await session.getState());
final returnCode = await session.getReturnCode();
final output = await session.getOutput();
final log = await session.getLogsAsString();
debugPrint("FFmpeg process exited with state $state and rc $returnCode");
debugPrint("FFmpeg Output: $output");
debugPrint("FFmpeg Log: $log");
if (ReturnCode.isSuccess(returnCode)) {
debugPrint("FFmpeg processing completed successfully.");
debugPrint('Audio successfully saved');
onSave(outputPath);
} else {
debugPrint("FFmpeg processing failed.");
debugPrint('Couldn\'t save the audio');
onSave(null);
}
});
}
Hi,
I want to trim audio file. When I use easy audio trimmer, it failed with error message like below.
_trimmer.saveTrimmedAudio( startValue: _startValue, endValue: _endValue, audioFileName: 'savetrimmer2', outputFormat: FileFormat.mp3, //outputFormat: 'm4a' as FileFormat, applyAudioEncoding: true, onSave: (outputPath) { setState(() { _progressVisibility = false; }); debugPrint('OUTPUT PATH: $outputPath'); }, );
I/flutter ( 4425): Exists I/flutter ( 4425): Retrieved Trimmer folder I/flutter ( 4425): Start: 0:00:00.000000 & End: 0:00:03.072000 I/flutter ( 4425): /data/user/0/kr.gainsys.imagetalk/app_flutter/Trimmer/ I/flutter ( 4425): FFmpeg process exited with state COMPLETED and rc 1 I/flutter ( 4425): FFmpeg processing failed. I/flutter ( 4425): Couldn't save the audio I/flutter ( 4425): OUTPUT PATH: null