ffmpeg-convert-audio/functions/index.js
/**
 * Utility method to convert audio to mono channel using FFMPEG.
 */
Utility method to convert audio to mono channel using FFMPEG.
Utility method to convert audio to mono channel using FFMPEG .
function reencodeAsync(tempFilePath, targetTempFilePath) {
  return new Promise((resolve, reject) => {
    const command = ffmpeg(tempFilePath)
        .setFfmpegPath(ffmpeg_static.path)
        .audioChannels(1)
        .audioFrequency(16000)
        .format('flac')
        .on('error', (err) => {
          console.log('An error occurred: ' + err.message);
          reject(err);
        })
        .on('end', () => {
          console.log('Output audio created at', targetTempFilePath);
        })
        .save(targetTempFilePath);
  });
}
function reencodeAsync ( tempFilePath , targetTempFilePath ) { return new Promise ( ( resolve , reject ) => { const command = ffmpeg ( tempFilePath ) . setFfmpegPath ( ffmpeg_static . path ) . audioChannels ( 1 ) . audioFrequency ( 16000 ) . format ( 'flac' ) . on ( 'error' , ( err ) => { console . log ( 'An error occurred: ' + err . message ) ; reject ( err ) ; } ) . on ( 'end' , ( ) => { console . log ( 'Output audio created at' , targetTempFilePath ) ; } ) . save ( targetTempFilePath ) ; } ) ; }
Utility method to convert audio to mono channel using FFMPEG.
Utility method to convert audio to mono channel using FFMPEG .