0

I'm trying to convert an mp3 file stereo to 2 mp3 mono node's fluent-ffmpeg module. This is example for terminal:

ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav

I need the implementation of this functionality in fluent-ffmpeg.

TGrif
  • 5,725
  • 9
  • 31
  • 52
obsidian
  • 1
  • 1
  • Any luck with `.outputOptions()` ? – TGrif Jan 22 '18 at 19:47
  • Maybe not related to your question but just a little heads up for what you are doing cause I am currently using `ffmpeg` in my project to accomplish some audio diarization process. The command you are using: ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav This will split the stereo audio into two mono audio files **with default bitrate (64k)**. With that being said, if you want to do some changes in the mono audio file and overlay them back to stereo type and the default bitrate (64k) is higher than the original audio file, then the final output will be larger in – User3301 Jun 29 '18 at 00:58

2 Answers2

1

not sure about the mono, but if you want to split a file, you can use

ffmpeg(local_dir).outputOptions('-f segment')
        .outputOptions(`-segment_time ${length of each mp3 }`).save(`${save_dir}out%03d.mp3`)

hope it can help you

m_____ilk
  • 143
  • 1
  • 15
0

It's been a long time since you've asked it, but maybe it can help to others.

The way I found to solve the same problem was opening the file twice and save each channel separated.

const splitChannels = (file, leftChannelName, rightChannelName) =>{

    ffmpeg(file)
        .outputOption('-map_channel 0.0.0')
        .save(leftChannelName)
        .on('error', (err) => {
            console.log(`An error occurred: ${err.message}`);
        })
        .on('end', () => {
            console.log('Left channel splitted!');
        })

    ffmpeg(pathToAudio)
        .outputOption('-map_channel 0.0.1')
        .save(rightChannelName)
        .on('error', (err) => {
            console.log(`An error occurred: ${err.message}`);
        })
        .on('end', () => {
            console.log('Right channel splitted!');
        })
}

splitChannels('./files/test.wav', 'left.wav', 'right.wav');

More info: https://trac.ffmpeg.org/wiki/AudioChannelManipulation

Of course you can use .wav or .mp3 too.

Hope it helps!