On my node.js server I want to convert a wav file to apple lossless .m4a
Using fluent-ffmpeg, I got this so far:
const transcoder = ffmpeg(fs.createReadStream(`${__dirname}/convertTest.wav`));
transcoder
.withAudioCodec('alac')
.addOutput(fs.createWriteStream(`${__dirname}/test2.m4a`))
.run()
;
But it throws me the following error:
Error: ffmpeg exited with code 1: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
I read that mp4 container needs a seekable file an therefore doesn't work with streams. So this actually works:
const transcoder = ffmpeg(`${__dirname}/convertTest.wav`);
transcoder
.withAudioCodec('alac')
.save(`${__dirname}/test2.m4a`)
.run()
;
Since I have all files as streams and not physical files, I am looking for way to somehow abstract this away to make it work with streams. Is this possible with fluent-ffmpeg?
The alac codec and .m4a format is non optional, so I need it to work with those formats.