Объединить изображения и видео, используя node-fluent-ffmpeg

Используемая библиотека Github: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg

я пытаюсь объединить некоторые изображения и видео (URL), используя node-fluent-ffmpeg на AWS Lambda.

Массив images содержит объекты для пути и цикла каждого изображения. видео содержат объекты пути каждого видео.

var command = fluentFfmpeg()
images.forEach(function(imageItem){
    command = command.mergeAdd(imageItem.path).inputFPS(1/imageItem.loop)
})
videos.forEach(function(videoItem){
    command = command.mergeAdd(videoItem.path)
})
command
.outputFPS(60)
.on('start', function (command) {
    console.log('ffmpeg process started:', command)
})
.on('progress', function(progress) {
    console.log('Processing: ' + progress.percent + '% done');
})
.on('error', function(err, stdout, stderr) {
    console.log('Error: ' + err, stdout, stderr);
    return callback(err);
})
.on('end', function() {
    console.log('Video file created succesfully');
    fs.readFile("/tmp/"+event.output_file, function (err, data) {
        if (err) {
            console.log("Error while reading /tmp/" +event.output_file+ " file", err);
            return callback(err);
        }
        var params = {
            Bucket: event.output_bucket,
            Key: event.output_file,
            Body: data
        };
        s3.putObject(params, function(err, data) {
            if(err){
                console.log("Error while uploading file in s3", err);
                callback(err);
            }else{
                console.log("Video File successfully uploaded to s3");
                callback(null, "success");
            }
        });
    });
})
.mergeToFile('/tmp/'+event.output_file, '/tmp/');

Я вижу это в консоли:

Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 800x400 [SAR 96:96 DAR 2:1], 25 tbr, 25 tbn, 25 tbc

Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 800x400 [SAR 100:100 DAR 2:1], 25 tbr, 25 tbn, 25 tbc

Stream #2:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 800x400 [SAR 1:1 DAR 2:1], 25 tbr, 25 tbn, 25 tbc

Stream #3:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 800x400 [SAR 72:72 DAR 2:1], 25 tbr, 25 tbn, 25 tbc

Stream #4:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 800x400 [SAR 96:96 DAR 2:1], 25 tbr, 25 tbn, 25 tbc

Stream #5:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 800x400 [SAR 1:1 DAR 2:1], 8626 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
  handler_name    : VideoHandler

Stream #6:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 800x400 [SAR 1:1 DAR 2:1], 258 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
  handler_name    : VideoHandler

Приставка:

Stream mapping:
Stream #0:0 (mjpeg) -> concat:in0:v0
Stream #1:0 (mjpeg) -> concat:in1:v0
Stream #2:0 (mjpeg) -> concat:in2:v0
Stream #3:0 (mjpeg) -> concat:in3:v0
Stream #4:0 (mjpeg) -> concat:in4:v0
Stream #5:0 (h264) -> concat:in5:v0
Stream #6:0 (h264) -> concat:in6:v0
concat -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[swscaler @ 0x5eb4340] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5eda2e0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5f01020] deprecated pixel format used, make sure you did set range correctly
[Parsed_concat_0 @ 0x57c4ea0] Input link in1:v0 parameters (size 800x400, SAR 1:1) do not match the corresponding output link in0:v0 parameters (800x400, SAR 96:96)
[Parsed_concat_0 @ 0x57c4ea0] Failed to configure output pad on 
Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #6:0
Conversion failed!

Размеры всех изображений одинаковы, но я получаю сообщение об ошибке при объединении изображений

{"errorMessage":"ffmpeg exited with code 1: Error reinitializing filters!\nFailed to inject frame into filter network: Invalid argument\nError while processing the decoded data for stream #6:0\nConversion failed!\n","errorType":"Error","stackTrace":["Failed to inject frame into filter network: Invalid argument","Error while processing the decoded data for stream #6:0","Conversion failed!","","ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/processor.js:182:22)","emitTwo (events.js:106:13)","ChildProcess.emit (events.js:191:7)","Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)"]}

Использование videoFilters дает ошибку, так как он не может быть забит с помощью complexFilter.

Нужна помощь с этим слиянием.

0 ответов

Другие вопросы по тегам