Learn how to set up and launch your first video transcoding job.

Setting up a complext transcoding job is easier than ever. If this is your first job, we recommend you start with the API Request Builder.

To launch a job using the start with the /v2/start_encodeapi method, which enables you to create full transcoding workflows using only the API. Encoding with the Custom Tasks also also offers a wider range of settings which can be used to fine tune your transcoding results.

1. Create a Project

Projects are the foundation of your transcoding workflow. Each Project offers an API key which can be used to automate transcoding workflows.

To create a Project, go to the ProjectsLink page and click Create a Project

If you already have a Project you want to use, go to Step 2

2. Authenticate API

The API instance is used to communicate with the Qencode REST API. To authenticate, use your API key.

#!/usr/bin/python
#-*- coding: utf-8 -*-
 
import qencode
 
API_KEY = '5e9e7c7ed566e'
client = qencode.client(API_KEY)

3. Create a Task

In order to start defining transcoding settings, you must first create a Task.

task = client.create_task()

4. Define Output Settings

Using the format object, define the formats, codecs and resolution combinations for each of the outputs you want to create.

{
  "query": {
    "format": [
      {
        "output": "mp4",
        "size": "1920x1080",
        "profile": "main",
        "bitrate": 4800,
        "video_codec": "libx264"        
      },
      {
        "output": "mp4",
        "size": "1280x720",
        "profile": "main",
        "bitrate": 3800,
        "video_codec": "libx264"
      },      
      {
        "output": "mp4",
        "size": "960x540",
        "profile": "main",
        "bitrate": 3000,
        "video_codec": "libx264"
      },      
      {
        "output": "mp4",
        "size": "640x360",
        "profile": "main",
        "bitrate": 1800,
        "video_codec": "libx264"
      },      
      {
        "output": "mp4",
        "size": "426x240",
        "profile": "main",
        "bitrate": 1200,
        "video_codec": "libx264"
      },
      {
        "output": "advanced_hls",
        "optimize_bitrate": 0,
        "stream": [
          {
            "size": "1920x1080",
            "profile": "main",
            "bitrate": 4800,
            "video_codec": "libx264"
          },
          {
            "size": "1280x720",
            "profile": "main",
            "bitrate": 3800,
            "video_codec": "libx264"
          },
          {
            "size": "960x540",
            "profile": "main",
            "bitrate": 3000,
            "video_codec": "libx264"
          },
          {
            "size": "640x360",
            "profile": "main",
            "bitrate": 1800,
            "video_codec": "libx264"
          },
          {
            "size": "426x240",
            "profile": "main",
            "bitrate": 1200,
            "video_codec": "libx264"
          }
        ]
      }            
    ],
    "source": "https://nyc3.s3.qencode.com/qencode/samples/1080-sample.mov"
  }
}

5. Launch Transcode

It's time to launch your transcoding jobs. Run the code below to kick off the process using the settings you've just defined.

To launch the transcoding job, run the following:

task.start_custom(QUERY)

Here’s the full code below:

6. Checking Status

You can check the status of your jobs once they have already been launched.

Use this script to periodically check the status of your transcoding job and get a live updates on the progress:

import time
import json

# using while loop

while 1:
  status = task.status()
  print json.dumps(status, indent=2, sort_keys=True)
  if status['error'] or status['status'] == 'completed':
    break
  time.sleep(3)

# using callback methods

def progress_changed_handler(status):
  if status['status'] != 'completed':
    print json.dumps(status, indent=2, sort_keys=True)

def task_completed_handler(status, task_token):
  print 'Completed task: %s' % task_token
  print json.dumps(status, indent=2, sort_keys=True)

task.progress_changed(progress_changed_handler)
task.task_completed(task_completed_handler, task.task_token)

TABLE

POSSIBLE STATUS VALUES

downloadingVideo is being downloaded to Qencode server.
queuedTask is waiting for available encoders.
encodingVideo is being transcoded.
savingVideo is being saved to destination location.
completedThe transcoding job has completed successfully and the videos were saved to the destination.