Nexrender: `help-wanted` 2 or more projects

Created on 11 Sep 2017  路  6Comments  路  Source: inlife/nexrender

Hey there, maybe you have some sort of example/code snippet how to make 2 or more projects by one run? Thanks!

Most helpful comment

Just a small fix for your code:

instead of only using array.pop:
let project = projects.pop();

You have to initiate a new class since your project.js requires it:
let project = new Project(projects.pop());

IT works perfectly. now I'm going to try solve the project naming challenge and saving the templates instead of unlinking them after render. Thanks!

All 6 comments

Hello,

What do you mean by "one-run" ?

I mean like "node start.js" and it results 2+ projects by one run. For example, i have one template and i want to make 3 videos for 3 countries. The things are the same, just images are different. So I have this:

let project = new Project(
    {
        "template": "projektaz.aepx",
        "composition": "comp1",
        "type": "default",
        "settings": {
            "outputModule": "Lossless"
        },
        "assets": [
            { "type": "project", "name": "projektass.aepx",  "src": `http://localhost:${port}/assets/${aepxfile}`}, //1024x683 / 1280 720
            { "type": "image",   "name": "Fotolia_45139233_Subscription_Monthly_M.jpg",  "src": `http://localhost:${port}/assets/${background1}`, "filters": [ {"name":"cover", "params": [1688, 1126] }] },
            { "type": "image",   "name": "Fotolia_82766733_Subscription_Monthly_M.jpg",  "src": `http://localhost:${port}/assets/${background2}`, "filters": [ {"name":"cover", "params": [1688, 1126] }] },
            { "type": "image",   "name": "Fotolia_85037185_Subscription_Monthly_M.jpg",  "src": `http://localhost:${port}/assets/${background3}`, "filters": [ {"name":"cover", "params": [1688, 1126] }] },
        ]
    }
);

and this is the data for one video, but i want 3 videos f.ex. I tried to create 3 new let's for project class, but it renders just first one and he skips other two. I'm still a Junior dev so sorry in advance.. 馃

oh i see
well you've created 3 projects, but i believe you are still running only one of them
cuz the actual render code for your needs can look like this:

// start rendering
renderer.render(aebinary, project1).then(() => console.log('project1 finished')).catch(err => console.error(err));
renderer.render(aebinary, project2).then(() => console.log('project2 finished')).catch(err => console.error(err));
renderer.render(aebinary, project3).then(() => console.log('project3 finished')).catch(err => console.error(err));

also, if you i suggest you to read more about js promises, this is a good concept to understand for any js environment/project

I've came across it before, but I'm trying to figure out f.ex. if i have 200+ videos or unknown ammount and use some alternative like array.length . I've tried to make a for loop and repeat it 5 times [still hardcoded, but less code], but it started to render all at once and, of course, it stuck on loop and crashed. I'm also thinking of recursive counter and somehow i thought you will be definitely using this.. :D

oh in case if you need variable amount of videos to render i can suggest you something like this:

let projects = []; // lets say this is array with Project objects

function render() {
    if (!projects.length) {
        return console.log('no more projects');
    }

    // otherwise take project and start rendering
    let project = projects.pop();

    // after finish or error, it will pick up next item recursively and start rendering
    renderer.render(aebinary, project).then(() => {
        console.log('one of the projects finished'); render()
    }).catch(err => {
        console.error('error happened in one of the projects', err); render()
    })
}

// start 3 rendering queues
for (var i = 0; i < 3; i++) {
    render();
}

Just a small fix for your code:

instead of only using array.pop:
let project = projects.pop();

You have to initiate a new class since your project.js requires it:
let project = new Project(projects.pop());

IT works perfectly. now I'm going to try solve the project naming challenge and saving the templates instead of unlinking them after render. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshea0 picture joshea0  路  5Comments

mackenly picture mackenly  路  5Comments

danielgwilson picture danielgwilson  路  3Comments

JamesBotterill picture JamesBotterill  路  4Comments

Morreski picture Morreski  路  5Comments