Created
January 24, 2024 10:42
-
-
Save lcssanches/ac151f9a78e4066a97eb2ae9e16b994e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export async function convertAudioToOgg(input: stream.Readable, output: string) { | |
return new Promise<void>((res, rej) => { | |
ffmpeg() | |
.input(input) | |
.audioChannels(1) | |
.audioCodec('opus') | |
.toFormat('ogg') | |
.addOutputOptions('-avoid_negative_ts make_zero') | |
.output(output) | |
.on('progress', function (progress) { | |
console.log('Processing: ' + progress.percent + '% done'); | |
}) | |
.on('error', function (err) { | |
console.log('An error occurred: ' + err.message); | |
}) | |
.on('end', (err, stdout, stderr) => { | |
console.log(err, stdout, stderr); | |
if (err) { | |
rej(); | |
} | |
res(); | |
}) | |
.run(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment