Tuesday 23 May 2017

FFMPEG (node.js) merge two webm video files

I am out after merging two video files with fluent-ffmpeg and end up with a merged mp4 file. Everything works just fine with the following function but the audio is not there in the output. Not sure what goes wrong with the sound. Any idea why that happens?

exports.mergeVertical = function()
{     
var fmt = ".webm"
return new Promise(function (resolve, reject) {     
    var proc = new ffmpeg();
    var output;
    proc.input("data/my/1.webm");
    proc.input("data/my/2.webm");

    proc.complexFilter([{
        filter: 'pad',
        options: {
            w: 'iw*2',
            h: 'ih'
        },
        inputs: '[0:v]',
        outputs: '[int]'
    }, {
        filter: 'overlay',
        options: {
            x: 'W/2',
            y: 0
        },
        inputs: ['[int]', "[1:v]"],
        outputs: '[vid]'
    }, ], output);
    proc.videoCodec('libx264');
    proc.outputOptions([
        '-map [vid]'
    ]);
    proc.output('data/my/output.mp4')
    proc.run();
    proc.on('progress', function (progress) {
        if (progress.percent != null) {
            console.log('vert: ' + progress.percent + '% done');
        } else {
            console.log('vert: ' + JSON.stringify(progress) + ' done');
        }
    });

    proc.on('error', function (err, stdout, stderr) {
        reject(err)
        console.log("-video: " + err);
        });

    proc.on('end', function () {
        resolve('data/my/output.mp4')
    })
});
}



via shamaleyte

No comments:

Post a Comment