Reputation: 13
I am trying to find the silent parts of an audio recording. This command does exactly what I want on my local machine.
ffmpeg -i http://twf-audio.s3.amazonaws.com/uploads/DBC50460-9A5C-4174-9885-07337A582D58_1377839443598_tell.m4a -af silencedetect=n=-40dB:d=0.2 -f null -
It sends a bunch of messages to the command line including these last three which are the lines of data that I need. (for reference: ffmpeg silencedetect docs)
[silencedetect @ 0x7feea040cf20] silence_start: 0.0321995
[silencedetect @ 0x7feea040cf20] silence_end: 0.975238 | silence_duration: 0.943039
[silencedetect @ 0x7feea040cf20] silence_start: 1.47184
I cannot figure out how to get that message out. Here is the nodejs code that is running. The only event that is triggered is the 'exit'. I thought that "pipe:1" sends output to stdout but that does not do anything.
var ffmpeg = spawn('ffmpeg', ['-i',filename,'-af','silencedetect=n=-40dB:d=0.2', '-f', 'null','-y', 'pipe:1' ]);
ffmpeg.on('message', function(data) {
console.log('ffmpeg2 PARENT got message:', JSON.stringify(data));
});
ffmpeg.stdout.on('data', function(data) {
console.log('ffmpeg stdout data = '+JSON.stringify(data) );
});
ffmpeg.on('exit', function (code, signal) {
console.log('child process exited with code:' + code + ' signal:' + signal);
});
Upvotes: 1
Views: 2621
Reputation: 432
The pipe:1
argument to ffmpeg sends the transcoded data stdout
.
The output that's shown when you run the command outside of node is sent to stderr
by default, and you can handle it in your program with:
ffmpeg.stderr.on('data', function(data) {
console.log('ffmpeg stderr data = '+data );
});
Upvotes: 2