convertFile method
Convert a sound file to a new format.
inputFileis the file path of the file you want to convertinputCodecis the actual file formatoutputFileis the path of the file you want to createoutputCodecis the new file format
Be careful : outfile and outputCodec must be compatible. The output file extension must be a correct file extension for the new format.
Note : this verb uses FFmpeg and is not available int the LITE flavor of Flutter Sound.
Implementation
Future<bool> convertFile(String? inputFile, Codec? inputCodec,
String outputFile, Codec outputCodec) async {
int? rc = 0;
inputFile = await _getPath(inputFile);
outputFile = await _getPath(outputFile);
if (inputCodec == Codec.opusOGG &&
outputCodec == Codec.opusCAF) // Do not need to re-encode. Just remux
{
rc = await flutterSoundHelper.executeFFmpegWithArguments([
'-loglevel',
'error',
'-y',
'-i',
inputFile,
'-c:a',
'copy',
outputFile,
]); // remux OGG to CAF
} else {
rc = await flutterSoundHelper.executeFFmpegWithArguments([
'-loglevel',
'error',
'-y',
'-i',
inputFile,
outputFile,
]);
}
return (rc == 0);
}