Whether you are developing your application in Rails or in any other language, you’ll find that encoding the videos and extracting thumbnails from them means an extra load on your application server. To reduce this load (and the associated cost) on your application server, you might want to use an external service that processes and converts the videos.

In this post we will explain how to convert videos and extract thumbnails using Transloadit. Take notice that some of the steps will be specific to Rails, but they can be easily replaced by Java or any other language.

The approach you will find in the Transloadit documentation shows how to upload files from a web application. But, if you have a mobile app or any other approach where you have a REST API or backend service that handles videos, you will also find this post useful, so keep on reading!

The first approach when using Mobile App + Rails Rest API + Amazon S3

Transloadit approach when using Mobile App + Rails Rest API + Transloadit + AmazonS3

Create a Transloadit template

First, go to https://transloadit.com/ and sign up. From your Transloadit account, create a new template and state the steps for transforming your video.

Then, name the template; in our example, we have named it “demo”. Following up, edit the template JSON with the required steps.

You may read more about the Transloadit robots and their options in the Robot API documentation.

In our example, we are importing a video from S3 (providing only the url), extracting a thumbnail from the middle of the video, encoding the video as an mp4 file with 1024x768 resolution, and storing the thumbnail and the encoded video in S3.

You may use parameters with this syntax: “${fields.param_name}” .

Each step has an input and a result. When creating templates, you can chain steps so that the input of a step turns into the output of the previous one. To achieve this, specify the value of “use”.

The template we created has the following flow:

Testing your template

After you have finished editing the template, you can manually test it to make sure that it works properly.

You will see a form with as many input fields as parameters you have in the template.

Firstly, you should input the video path as import url, then the path within the S3 bucket where you want the video, and finally, the image to be stored.

Remember to put a real video file in the Amazon bucket before running the test.