stream-transcoder.js
stream-transcoder.js copied to clipboard
Transcode a Movie on the Fly
Hi
I have a webm file in my File System and i am trying to transcode it to MP4 to be played in IE, Safari
the code is as follows:
app.js
var httpServer = require('http'); var Transcoder = require('stream-transcoder');
var server = httpServer.createServer(function(req, resp) { if(req.url == "/transcode") { console.log("Inside Transcode");
resp.setHeader('Access-Control-Allow-Origin', '*');
resp.writeHead(200, {'content-type':'video/mp4'});
new Transcoder("12003.webm")
.maxSize(320, 240)
.videoCodec('h264')
.videoBitrate(800 * 1000)
.fps(25)
.audioCodec('libfaac')
.sampleRate(44100)
.channels(2)
.audioBitrate(128 * 1000)
.format('mp4')
.on('finish', function() {
next();
})
.stream().pipe(resp);
}
} server.listen(8000);
when i open the url in Browser(s), the HTML5 video is not playing it shows only blank image.
the html code is
index.html
Do i need to set content headers.. How can i render this stream as buffered, partical content or what should i do so that video gets played
regards Shafi
The file is in right path where the node.js file is. That is not the problem.
any sugestions ?
@mshafieluru check this