This post provides insights on the new features available in Cinegy Convert v11 (pending for release). With powerful pre- and post-scripting events it is possible to extend your workflow way further the out-of-the-box functionality, for example, automatically publish videos on Facebook on user’s behalf. Source codes are also available for the reference.

Introduction

The idea behind Hacking Cinegy presentations during TechCon 2017 is to demonstrate tips and tricks that can be used to extend functionality of your products using open Cinegy architecture and APIs. The latest demo showed the following features:

Cinegy Convert Processing Scripts

While Cinegy Convert v11 is still pending for the release, it is already available as pre-release version for download and feedback. Having a collection of nice new features available, Cinegy Convert v11 is worth trying in your workflow as it may greatly simplify the process and make it more robust.

During the demo, Cinegy Convert pre- and post-processing script capabilities were shown in order to:

  • Generate new metadata as a pre-processing step;

  • Upload a video file to Facebook as a post-processing step.

Pre-Processing

Cinegy Convert v11 does provide an option to perform additional initialization steps when the task is about to be processed. This allows, for example, scan source media to generate additional metadata, perform sanity checks and cancel the task when necessary, etc.

Pre-processing profile

The sample script demonstrates how operator can access task logs to generate additional informational messages, access already existing metadata and generate new ones.

The script input parameter provides access to the Cinegy.Media.Linker.Strategies.ScriptOptimizationProvider interface, which is a common access point to other available capabilities. For example, the Cinegy.Logging.ILogger interface is accessible via $provider.Logger. Once logger access is received, additional log messages can be added to the task processing logs via $logger.Info / $logger.Warn / $logger.Error / $logger.Fatal / $logger.Trace calls.

The available metadata can be accessed via $provider.Metadata['<macro>'], where <macro> defines the name of the metadata item to be retrieved, for example {src.name}. The new metadata generated during the pre-processing script execution can be registered using $provider.AddMetadata(<macro>', $value). Once registered, the new metadata can be referenced, for example, in the profile parameters:

Pre-processing

The demo script provided shows how to generate new TrafficProgrammId metadata from the source file name truncating the special substring NRHD when necessary.

Post-Processing

Cinegy Convert v11 does provide an option to perform additional steps when the task is completed. This allows you, for example, to move the generated media to another location, send notification messages about new media available, publish media in the WEB, etc.

The sample script demonstrates how operator can automatically upload media to Facebook and register a new post on behalf of the selected user.

In order to simplify the demo, the process of receiving Facebook authorization token for the media upload is left out of scope for the script. Nevertheless, the manual token generation process is described.

Introduction

In order for an application to publish content on Facebook user’s behalf, several steps should be performed:

  • application registration;

  • authentication token generation on user’s behalf;

  • uploading the media using Facebook SDK.

Application Registration

In order for the application to have access to Facebook API, it has to be registered with Facebook. To do this, you have to be promoted to the "Facebook developer" role.

Once registered as a developer, you will be able to create applications that can access the Facebook API:

Facebook App

The details for the new application should be specified:

Facebook App Register

Authentication Token

Once the application is created, you are able to access its details and generate test authentication tokens on user’s behalf. To do this, use the Access Token Tool from Facebook.

You are able to generate user access token with limited life time:

Facebook UAT Limited

Although the default life time is limited, so for the practical purposes you will have either to renew the access token via API or generate the token with extended life time (30 days):

Facebook UAT Extended

Once the extended user access token is generated, copy the provided data and save it as a Convert-Facebook-AccessToken.txt file in the folder specified in the PowerShell script.

Facebook API

There are a lot of ways to access Facebook API. In order to simplify the script, we used Facebook SDK.

Once NuGet package is downloaded, specify the path to Facebook.dll in the PowerShell script.

Running the Script

Once all preliminary steps are done, the rest is very simple. The script just loads the Facebook SDK assembly, creates a Facebook.FacebookClient object to access the API, specifies previously generated access token, and uploads the media file generated by Cinegy Convert using the $fb.Post("/me/videos", $parameters) call. As simple as that 😊!