Common Examples

All of these examples assume that the FX SDK is required, credentials are loaded, and the region is set. Some of the examples also assume that you run a HTTP server framework like Express, Hapi or httpdispatcher to handle requests.

The common preamble code can be summarized as follows:

FX = require('impossiblefx-sdk');
FX.config.apikey = 'APIKEYXXXX';
FX.config.apisecret = 'ApiSecretXxXxXxX';
FX.config.region = 'eu-west-1';

express = require('express');
app = express();

Basic Usage

The following examples how to request a poster frame from a dynamic movie:

var render = new FX.Render({params: {ProjectId: 'PROJECT_ID', Movie: 'MOVIE_NAME'}});
var frame_number = 100;

render.getPosterFrameURL({
    Params: {name: req.query['name']}
    Frame: frame_number  
}, function(err, data){
    console.log("Poster frame URL is:", data.URL)
})

Usage in a Node.js Express Server

The following example shows how to handle a client request, create a FX render request and to return the generated video URL in a server:

var render = new FX.Render({params: {ProjectId: 'PROJECT_ID', Movie: 'MOVIE_NAME'}});

app.get('/video', function(req, res) {
    render.getRenderURL({
        Params: {name: req.query['name']}    
    }, function(err, data){
        res.send(data.URL)
    })
});

Create a Project and Movie programmatically

var prj = new FX.Project()
prj.createProject({Name: "PROJECT_NAME"}, function(err, data){
    
})

Terms of Use | © 2017, Impossible Software, or its affiliates. All rights reserved.