Open anurag-gethullo opened 8 years ago
Looks like a ffmpeg issue. Can you please try with command line ffmpeg first and report back if it works ?
Hey thanks for your reply.
command line ffmpeg works fine:
ffmpeg -f m4a -i audio.m4a -acodec libmp3lame -f mp3 output.mp3
if I give the file path instead of streams it works as expected
the file path code is:
ffmpeg(__dirname + "/audio.m4a")
.withNoVideo()
.inputFormat('m4a')
.audioCodec('libmp3lame')
.audioBitrate(128)
.format('mp3')
.on('error', (err) => console.error(err))
.on('end', () => console.log('Finished!'))
.pipe(fs.createWriteStream("streamed.mp3"));
The only problem I'am facing is with streams
If i call the ffmpeg code on "end" event of streams in that case it throws an error
throw new Error('Invalid input');
the complete stack trace of it is:
Error: Invalid input
at FfmpegCommand.proto.mergeAdd.proto.addInput.proto.input (/Users/anuragtiwari/Code/RND/ffmpeg-fulent/node_modules/fluent-ffmpeg/lib/options/inputs.js:34:15)
at new FfmpegCommand (/Users/anuragtiwari/Code/RND/ffmpeg-fulent/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:51:10)
at FfmpegCommand (/Users/anuragtiwari/Code/RND/ffmpeg-fulent/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:34:12)
at ReadStream.<anonymous> (/Users/anuragtiwari/Code/RND/ffmpeg-fulent/index.js:39:6)
at emitNone (events.js:72:20)
at ReadStream.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:921:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
Can you please confirm if the same code works for you with streams?
command line ffmpeg works fine:
ffmpeg -f m4a -i audio.m4a -acodec libmp3lame -f mp3 output.mp3
if I give the file path instead of streams it works as expected
You already knew it worked fine with file paths. What needs to be tested is using pipes on command line.
I get a similar issue (Error: Invalid input
at FfmpegCommand.proto.mergeAdd.proto.addInput
) and it is caused by my input stream being a through2
stream (progress-stream
actually). Since it is a custom transform stream it does not have the "readable" flag set.
I am having the same problem. It works with file paths and does not work with streams
Hi, anyone has a solution for it ?
I just got this bug also
I'm also experiencing this issue. I can convert when the m4a is a file, but piping it from a stream claims 'partial file'. This SO question says that "ffmpeg in streaming mode needs that header information to be near the beginning of the file. Fixing the file using ffmpeg -acodec copy -movflags faststart works for me." https://stackoverflow.com/questions/52543595/problem-using-ffmpeg-in-streaming-mode-on-aac-files-created-by-android
Hi, I still can't make it work... even after following @mitchell-bu proposal (on SO) What i want to do is convert from m4a to wav.
let chunks = [];
Ffmpeg(inputStream(content))
.audioCodec('pcm_s16le')
.audioChannels(1)
.format('wav')
.outputOptions('-movflags faststart'); //-acodec copy <= this does not seem to be supported (?)
.on('end', () => { console.info(finished.
); })
.on('error', (err) => { console.error(error is ${err}
); });
const ffstream = command.pipe({end: true});
ffstream.on('data', function (chunk) {
chunks.push(chunk);
});
I just added the outputOptions line to solve the m4a to wav conversion problem.
Note that command line ffmpeg -i myFile.m4a outFile.wav works fine .... Note also that the above code works fine for other audio format to wav conversion (removing the outputOptions line)
Where am i getting wrong ? Thx.
Any updates on this? We're experiencing the same at my company and we are unable to fix it. CMD works fine.
Has there been an update on this issue? I am currently facing an issue and unable to find a workaround
I am also unable to find a workaround, I can't tell if this is a bug with ffmpeg or fluent ffmpeg, has anybody tried filing a report with ffmpeg regarding this?
Just got this bug and realized this has existed since 7 years ago.
I find even more crazy how nobody has found a solution, or even a workaround yet
I also need a solution for this problem, anyone has find a workaround?
this is not a problem with fluent-ffmpeg as mitchell-bu said. the headers of m4a are at the end of file so stream can have problem.
adding .inputOptions('-codec:a' ,'libfdk_aac')
may solve this
When I run fluent-ffmpeg with file path, it gives me an proper output, but while running the same script with file stream reader it generates an mp3 which only contains ffprob _ID3 TXXX major_brandM4A TXXX minor_version512TXXX compatiblebrandsisomiso2TSSE Lavf57.41.100 My code is:
The wired thing for me is why the same audio.m4a is working great with file path, but not working with streams? FYI i am working on my local machine.