Friday 5 May 2017

FFMpeg not merging videos well in Nodejs on same file

I am using MediaStreamRecorder to make a stream, I am getting video blobs from there every 5 seconds and i want to concatenate them in one file on server-side. So lets say i have a video named sample_1.mp4 . When i get the next video, i want to save it as sample_2.mp4 , and append it to sample_1.mp4 with ffmpeg, and after that save the output as sample_2.mp4 again.But it only saves first video and the last video parts.Can you help me please? Thanks.

            var fs = require('fs');
            fs.writeFileSync("/sample_2.mp4", message.binaryData );
            console.log("The file3 was saved!");
            var firstFile = "/sample_1.mp4";
            var secondFile = "/sample_2.mp4";
            var output = "/sample_2.mp4";
            var proc = ffmpeg(firstFile)
            .input(secondFile)
            .on('end', function() {
                console.log('files3 have been merged succesfully');
            })
            .on('error', function(err) {
                console.log('an error happened: ' + err.message);
            })
            .mergeToFile(output, "/tmp");



via G.Darcan

No comments:

Post a Comment