Created
September 14, 2018 21:54
-
-
Save ThunderWiring/87c9a81f4ebd57f9e2f8ac3ee7e95dd9 to your computer and use it in GitHub Desktop.
extract audio in MP3 format from an MP4 file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @private | |
*/ | |
extractAudioFromMP4_(paths) { | |
return new Promise((resolve, reject) => { | |
/* | |
for some reason, this did not work: | |
const binaries = require('ffmpeg-binaries'); | |
const ffmpegPath = binaries.ffmpegPath(); <-- throws an exception | |
so i had to assign the path explicitly.. | |
*/ | |
const ffmpegPath = 'C:\\Projects\\mp3converterNodeJs\\node_modules\\ffmpeg-binaries\\bin\\ffmpeg.exe'; | |
ffmpeg(paths.filePath) | |
.setFfmpegPath(ffmpegPath) | |
.format('mp3') | |
.audioBitrate(160) | |
.on('progress', (progress) => { | |
}) | |
.output( | |
fs.createWriteStream( | |
path.join(paths.folderPath, sanitize(paths.fileTitle)))) | |
.on('end', () => { | |
resolve(); | |
}) | |
.run(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment