Created
September 3, 2014 23:18
-
-
Save revolunet/368031b56dfed0237a10 to your computer and use it in GitHub Desktop.
mp3 to ogg
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
/* mp3 to ogg | |
this gives : | |
events.js:72 | |
throw er; // Unhandled 'error' event | |
^ | |
Error: only signed `32-bit` float samples are supported, got "16" | |
*/ | |
var opts = { channels: 2, bitDepth: 32, float: true }; | |
var inStream = fs.createReadStream(process.argv[2]); | |
var outStream = fs.createWriteStream(new Date().getTime() + '.ogg'); | |
var mp3Decoder = new lame.Decoder(); | |
var mp3Encoder = new lame.Encoder(opts); | |
var oggEncoder = new ogg.Encoder(); | |
var vorbisEncoder = new vorbis.Encoder(opts); | |
vorbisEncoder.pipe(oggEncoder); | |
// re-encode incoming mp3 to 32bits | |
var mp3_32 = inStream | |
.pipe(mp3Decoder) | |
.pipe(mp3Encoder) | |
.pipe(mp3Decoder); | |
// convert to vorbis and save | |
mp3_32.pipe(vorbisEncoder) | |
.pipe(oggEncoder) | |
.pipe(outStream); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment