Nexrender: Adding post rendering tasks?

Created on 17 Jan 2017  路  21Comments  路  Source: inlife/nexrender

First of all, thank you for such a great application. This is exactly what I was looking for. I appreciate it so much and I would like to contribute this project in the future.

I have a question. After following your instructions, I was able to render my project with render node & the api-server with a request from front-end. From the description #9 on wiki, it says that I could add post rendering tasks after rendering node finishes its job. I would like to upload the video on youtube after rendering. How can I do that? Should I modify the render node code? Can you help me navigate where that is? Thank you!

question

All 21 comments

Hello,

Thank you! Im very pleased to hear that. :)

post rendering tasks

This option was planned. And was even kind-of made, until i striped it from the project. Because i did not find a way to do this properly. And now its kinda frozen :p

Anyways, i see a few different ways or doing that:

  1. Launch rendernode from some kind of host, which will listen to changes in console, and as soon as it'll see "project finished" or smth. like this, it will trigger new actions.
  2. Launch a 3rd app, which will be running on the same server as rendernode, and listening using nexrender api to talk to api server. And as soon as it'll see api finished rendering - it will take actions.
  3. Launch rendernode in serverless mode (like in inlife/nexrender-boilerplate), and listen to finished callback.

Hello,

I guess I will either go with the option 2 or 3. It looks like the option 3 is the easiest. If I go with the option 3, what will be the disadvantages? Can you have multiple instances using 3?

I am planning to do something like this below.

'use strict';

var Project   = require('nexrender').Project;
var renderer  = require('nexrender').renderer;

var project = new Project({
    'template': 'MyTemplate.aepx',
    'composition': 'MainComp',
    'settings': {
        'outputModule': 'JPEG', // check your AE for existing output module
        'outputExt': 'jpg'
    },
    'assets': [
        {
            'type': 'project',
            'src': 'http://127.0.0.1:31999/MyTemplate.aepx',
            'name': 'MyTemplate.aepx'
        }, {
            'type': 'image',
            'src': 'http://127.0.0.1:31999/HotAirBalloon.png',
            'name': 'HotAirBalloon.png'
        }, {
            'type': 'script',
            'src': 'http://127.0.0.1:31999/test.js',
            'name': 'test.js'
        }
    ]
});

// start rendering
// NOTE: i inserted path to my aerender binary
// if you are on windows, your path might look like:
// 'C:\\Program Files\Adobe\After Effects CC 2015\aerender.exe'
var rendered = renderer.render('/Applications/Adobe After Effects CC 2015.3/aerender', project);

rendered.then(function() {
    // successfully rendered
    console.log('yay!');
});

Yea, you can have multiple instances with 3rd option. Whatever quantity of aerender processes will your system support. (same like multiple After Effects rendering rendering at the same time)

what will be the disadvantages

you'll dont have ability to monitor current projects via api, and mostly thats it :p

Thank you, I will go with the 3rd option to test things out.

Just one more question.
If I wanted to scale it up, it should be structured as below, right?
screen shot 2017-01-17 at 4 17 13 pm

Hm, if all this network will be set up on different machines (like real network), then it'll be hard for you to make web/api server responsive for uploading vids to youtube. Considering fact that rendered file will be stored on the particular rendernode.

Its either you move file after the render succeeded to a web/api server via some rsync/p2p file transfer. Or, upload right from the rendernode (which in most cases will be easier and faster).

P.S. Also, you can modify 3rd option, to work with an api server, like it does with rendernode itself.
So it will be like a override customization for rendernode defaullt behaviour, where youll be able to add your custom steps.

This can be achieved by combining these 2 code examples:
API-Wrapper
Custom Node

I am sorry, can you explain this part in more detail?

P.S. Also, you can modify 3rd option, to work with an api server, like it does with rendernode itself.
So it will be like a override customization for rendernode defaullt behaviour, where youll be able to add your custom steps.

Yep, I think I understood what you meant. Thank you so much!!

somewhere, maybe from your desktop event, you create the project via api (like it shown in the example)

var api = require('nexrender').api;

// Configure api connection
api.config({
    host: "localhost",
    port: 3000
});

// Define project properties
var assets = [{
    type: 'image',
    src: 'https://dl.dropboxusercontent.com/u/28013196/avatar/mario.jpeg',
    name: 'image.jpg'
}];

// Create project
api.create({
    template: 'template1.aepx',
    composition: 'base',
    assets: assets
}).then((project) => {

    console.log('project saved');

    project.on('rendering', function(err, project) {
        console.log('project rendering started');
    });

    project.on('finished', function(err, project) {
        console.log('project rendering finished')
    });

    project.on('failure', function(err, project) {
        console.log('project rendering error')
    });
});

and custom rendernode code exmaple:

var api = require('nexrender').api;
var renderer  = require('nexrender').renderer;

// Configure api connection
api.config({
    host: "localhost",
    port: 3000
});

// connect to api, fetch queued projects, and start rendering
api.get().then(function(results) {
    // iterate, find queued
    for (let project of results) {
        if (project.state === 'queued') {
            return startRendering(project);
        }
    }
});

function startRendering(project) {
    var rendered = renderer.render('/Applications/Adobe After Effects CC 2015.3/aerender', project);
    rendered.then(function(project) {
        // apply some custom steps, upload to youtube from there, for example

        // and mark project as finished (updates api state, and triggers remote callbacks)
        project.finish();
    });
}

also, you always can create projects via POST requests to the api from any convenient tool with json
even via curl :D

Wow, you are awesome!! Thank you!!

I will create a demo app with a simple front-end like uploading an image. If you are interested, I will let you know when that is done. Thank you again!

Yea, that would be great !)
Kinda interesting too see what people can do with this thingy :D

You are very welcome! )

@syson16 Did you manage to get this running? Would love to see your results. I am currently trying to create something similar from a front-end that then returns the video created to the user.

I started building but couldn't actually finish it yet because of work..

@syson16 @wst-shorty : do you have any new plan for your features?

Maybe add to the project model new attribute webhooks, so when render will be done just send project to the webhook link:

{
   "failed": "https://example.com/api/v1/render-callback",
   "finished": "https://example.com/api/v1/render-callback"
}

Hi,

I'm not quite sure how this can work:

// Create project
api.create({
    template: 'template1.aepx',
    composition: 'base',
    assets: assets
}).then((project) => {

    console.log('project saved');

    project.on('rendering', function(err, project) {
        console.log('project rendering started');
    });

    project.on('finished', function(err, project) {
        console.log('project rendering finished')
    });

    project.on('failure', function(err, project) {
        console.log('project rendering error')
    });
});

If my admin app creates new projects (and send it to the nexrender server via this api client), how is subscribing to this .on events can even work? where does the nexrender server informs my app that rendering is started/finished? how can this console.log('project rendering started'); be even printed?

@matanregev render node send update/put requests to the API server and update project status when status updated on API server it executes subscribed functions. If I remember correctly API server check status every minute within 20 minutes.

yes, basically if you api client knows that you've started listening to some projects which are rendering, it will be fetching and HTTP update for particular project every one minute.
That time frame can be configured though.

I'm not sure how useful this is for all use cases, but perhaps it will be helpful to someone.

In my recent project I took a slightly different approach to accomplishing post rendering tasks. Basically, I added a new task upload after cleanup which uploads the result video to a specified S3 bucket. From there, we trigger post rendering tasks (e.g., emailing the video, uploading it to youtube) via another app which checks the S3 bucket for new videos every few minutes.

This approach worked well for my project because it allowed us to handle our post render tasks outside of node which provided some extra flexibility (in our case we used PHP for reasons related to project requirements, but any language with an AWS package would work). You could also potentially handle post render tasks via AWS Lambda this way, but I haven't been quite that ambitious yet.

If there is interest for this post-render upload feature, I could spend some time making it configurable (and perhaps supporting more upload targets than just S3) and try to get it merged into the next release.

issue is resolved, for more info follow #68

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielgwilson picture danielgwilson  路  3Comments

FRANK-AND-FREE picture FRANK-AND-FREE  路  4Comments

amarCosmospace picture amarCosmospace  路  3Comments

Dezzymei picture Dezzymei  路  3Comments

byumark picture byumark  路  3Comments