How to set up a task?

Definition of a Task

A task represents a single instance of a transcoding job that applies a particular template to a specific source video. When you create a task, you choose the desired template, provide the input video’s location, and specify an output path along with a storage destination. The AuroraCloud VOD service then processes the input video according to all the parameters defined in the referenced template, delivering a transcoded output. Tasks can be monitored to track real-time status (e.g., “running,” “succeeded,” or “failed”) and can be queried to retrieve information such as start time, end time, and error messages if any issues occur during processing.

Summary

This document will guide you through the process of creating a task, including setting up inputs, selecting templates, and configuring outputs. Please ensure that your input files are ready and the Output is properly configured.


Steps to Create a Task

Step 1: Log in to the Console

  1. Access the console and log in using your account credentials.

Step 2: Navigate to the Task Page

  1. After logging in, select VOD -> Task from the left navigation bar.

    Recording Configuration

Step 3: Create a New Task

  1. On the Task page, click the Create a new Task button.

    Recording Configuration

Step 4: Set Up Input

Currently, three input methods are supported:

  1. Video URL: Enter the URL link of the video file.

  2. Upload Video: Upload a local video file.

  3. Sample Video: Select a sample video provided by the system.

    Recording Configuration

Step 5: Select a Template

Currently, two types of templates are supported:

  1. Custom Template: Customize the task processing template according to your needs.

  2. Predefined: Choose a system-predefined template.

    Recording Configuration

Step 6: Configure Output

  1. Click Select to choose a pre-configured Output.

  2. Set the Output Filename to specify the name of the output file.

    Recording Configuration

Completion

  • After completing the above steps, click Confirm to successfully create the task.

Important Notes

  • Ensure that the input file or URL is valid to avoid task failure.

  • If selecting a custom template, configure the template parameters in advance.

  • Ensure that the Output is correctly configured so that the task results can be successfully exported.

Creating a Transcoding Task via API

import requests
from typing import Optional
def create_transcode_task(api_key: str, api_secret: str, template_name: str, input_file: str, output_file: str, storage_id: str) -> Optional[str]:
"""
Create a transcoding task
Args:
api_key: Access Key ID for API authentication
api_secret: Access Key Secret for API authentication
template_name: Name of the transcoding template
input_file: URL or path of the input file
output_file: Path for the output file
storage_id: ID of the storage space
Returns:
Task ID if successful, None if failed
"""
url = "https://api.visionular.com/vodencoding/v1/create_task"
headers = {
"Content-Type": "application/json",
"auth-type": "use-basic"
}
payload = {
"template_name": template_name,
"input": input_file,
"output": output_file,
"storage_id": storage_id
}
try:
response = requests.post(
url,
headers=headers,
auth=(api_key, api_secret),
json=payload,
verify=True
)
response.raise_for_status()
result = response.json()
if result["code"] == 0:
task_id = result['data']['task_id']
print(f"Transcoding task created successfully! Task ID: {task_id}")
return task_id
else:
print(f"Creation failed: {result['msg']}")
return None
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")
return None
# Example usage
if __name__ == "__main__":
api_key = "your_api_key"
api_secret = "your_api_secret"
template_name = "System_DASH_MP4_H264"
input_file = "https://dangjin-iptest.oss-cn-beijing.aliyuncs.com/rakuten-japan/1102553305.mp4"
output_file = "output_dash/1102553305_2_dash.mpd"
storage_id = "34b3cad70dbf8ee1"
task_id = create_transcode_task(api_key, api_secret, template_name, input_file, output_file, storage_id)
if task_id:
print(f"Task created successfully. Task ID: {task_id}")