var fs = require('fs');
var child = require('child_process');
var http=require('http')
var input_file = fs.createReadStream('./remo.mp3');
http.createServer(function (req,res) {
var args = ['-ss',120,
'-i', 'remo.mp3',
'-f','mp3',
'pipe:1' // Output on stdout
];
var trans_proc = child.spawn('ffmpeg', args);
res.writeHead(200, {
'Content-Type': 'audio/mpeg'
});
trans_proc.stdout.pipe(res)
trans_proc.stderr.on('data',function (err) {
console.log(err.toString());
})
}).listen(2000)
i am trying to cut the mp3 and streaming to the browser but in browser it showing corrupted file
I cannot tell if you're asking about downloading a youtube video as an mp3 using node - but this thread popped up on top of google when I was researching just that. So, if not, perhaps it can point you in the right direction or help someone in the future... Mods - sorry if I'm not doing this right.
Additional StackOverflow Reference
But I am using the following code to do download a youtube vid as mp3 (download youtube vid / convert to mp3 / download) :
};