i am trying to convert an audio file into a binary file using js or node.js, as i need it for my project
Here's the code that i have tried. the file got converted but is not in binary format.
fs.readFile('bell-ring-01.mp3', function(err, data) {
if (err) throw err;
var encodedmp3 = new Buffer(data, 'binary').toString(2);
if(encodedmp3)
{
console.log(encodedmp3);
}
//perform the encryption, then
fs.writeFileSync("music.sam", encodedmp3, function(err) {
if(err) {
return console.log(err);
}
// console.log(encodedmp3);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.