Closed Konglomneshued closed 1 year ago
I managed to get something working. The docs are not helpful.
const decodeSong = async (songPath: Path) => {
const ffmpeg = createFFmpeg({
log: true,
logger: message => console.log(message),
progress: progress => console.log(progress),
});
await ffmpeg.load();
const decodedSongPath = decodeURI(songPath);
const songData = await fetchFile(decodedSongPath);
const tempFolder = join(app.getPath('userData'), '.decoded-audio');
if (!existsSync(tempFolder)) {
mkdirSync(tempFolder);
}
const [ path, extension ] = decodedSongPath.split('.');
const songTitle = path.split('/').at(-1)!;
const originalFile = songTitle + '.' + extension;
const tempFile = songTitle + '.flac';
console.log(tempFile);
ffmpeg.FS('writeFile', originalFile, songData);
await ffmpeg.run('-i', originalFile, '-acodec', 'flac', tempFile).then(() => {
console.log('Finished');
}).catch(error => console.error(error));
return join(tempFolder, tempFile);
};
Still doesn't work, but I can see FFmpeg doing something. It's not saving the file, though.
Apparently I needed to use the FS method along with fetchFile to read/write the audio data to memory and then write the file with the Node fs module.
Please update the docs, so they are more helpful. I had no idea why I would use certain methods like FS unless I visit the demo.
Describe the bug FFmpeg doesn't seem to do anything. I have logger and progress, and tried the setProgress method, nothing prints to my console.
Expected behavior ffmpeg.run(...) convert my file to flac.
Screenshots If applicable, add screenshots to help explain your problem.
ffmpeg.run(...) produces no errors.
Doesn't create the file
Desktop (please complete the following information):