How to Set Up Notifications When Video Conversions Are Finished

Fri 28 March 2014 By Laurent Doguin

How to Setup Notifications when Video Conversions are Done?

Last week I blogged about video conversion profiles in the Nuxeo Platform. I explained how to configure them, add new, or disable existing ones. Today I will show you how to setup notifications when those video conversions are done. It's actually pretty simple.

There is a videoConversionsDone event launched each time a video conversion is done (who would have known?). Unfortunately, it's not available in Nuxeo Studio by default. But we can make it available thanks to the Nuxeo Studio registries.

To do that go to Settings and Versioning > Registries > Core Events. You should see a text editor. It accepts a JSON string that represents the event we want to add. Here it is:

events: {
videoConversionsDone: "Video Conversion Done"

Now click on save and create a new Event Handler. At the end of the Events list, you should see Video Conversion Done. Select it and create the associated operation chain.

This operation takes the Video document as input. The notification event is different than the usual one from the CoreSession (documentModified, documentCreated etc...). So we cannot use the CurrentUser object. It's null.

Instead, we have the Event object in the operation context. But the sad news is this user is System. This is because the video conversions are done inside a Worker by the System user. So if we want to send an email to the document creator or last modifier, we need to proceed differently.

In the Nuxeo Platform all the documents having the dublincore schema (all the default ones) have a Last Contributor property (dc:lastContributor). This is exactly what we need. This way we cover the creation and modification of the document. In Nuxeo Studio you can retrieve the email of the last contributor of a document with the following MVEL expression:


My final operation chain looks like this:

Fetch > Context Document(s)
Notification > Send E-Mail
from: [email protected]
message: template:videoConversionDone
subject: @{Document["dc:title"]} Video Conversion Done
to: @{Fn.getEmail(Document["dc:lastContributor"])}

The template:videoConversionDone property refers to an email template I created in the appropriate Nuxeo Studio section. Here's the template content:


The video conversions for the document <a href="${docUrl}">${Document['dc:title']}</a> are done.
How AWESOME is that?

The Nuxeo Platform

I talked about this with Thibaud and he went even further with this mail template:

<p>Conversions for <a href='${docUrl}'>${Document['dc:title']}</a> are ready:</p>
<p><ul><#list transcodedItems as oneItem>
<p>The Video Conversion Service</p>

This email lists all the conversions currently available on the document. He can do this because he has added the transcodedItems variable in the operation context. He did this by adding the Set Context Variable operation just before the Send E-Mail:

Execution Context > Set Context Variable
name: transcodedItems
value: @{Document['vid:transcodedVideos']}

If you want to go further, you can try adding thumbnails of the video in the email :)

Category: Product & Development
Tagged: How to, Nuxeo Studio