Launching your first video transcoding job via API
This tutorial will guide you on how to use Qencode's Transcoding API for creating, starting, and checking the status of a transcoding job. Here are the steps:
Step 1: Get Access Token
The access token is generated using your API key. You can find the API key in the Qencode portal. Follow these steps:
- Navigate to Transcoding -> Projects.
- Copy the API key. You can create a new project if needed.
Use the following API request to get the access token:
curl --location 'https://api.qencode.com/v1/access_token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'api_key=YOUR_API_KEY'
Replace YOUR_API_KEY
with your actual API key.
The server will respond with the access token, for example:
{
"error": 0,
"token": "5de1d971e45fa0f7a6dc77a05e893123",
"expire": "2023-08-02T13:42:23"
}
You can re-use the access token until it expires.
Step 2: Create Transcoding Job
Use the /v1/create_task
method to create the transcoding job:
curl --location 'https://api.qencode.com/v1/create_task' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'token=YOUR_ACCESS_TOKEN'
Replace YOUR_ACCESS_TOKEN
with your actual access token.
The server response will contain the task_token
value which is your transcoding job ID:
{
"error": 0,
"upload_url": "https://prod-us-central1-a-1-storage-gcp.qencode.com/v1/upload_file",
"task_token": "10566ad19601a465801ae56975750123"
}
Step 3: Start the Transcoding Job
Use the task_token
value when calling the /v1/start_encode2
API method to launch the transcoding:
curl --location 'https://api.qencode.com/v1/start_encode2' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'task_token=YOUR_TASK_TOKEN' \
--data-urlencode 'query={"query": {
"source": "https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4",
"format": [
{
"output": "mp4",
"height": "360"
}
]
}
}'
Replace YOUR_TASK_TOKEN
with your actual task token.
The server response will provide the status_url
:
{
"error": 0,
"status_url": "https://prod-us-central1-a-1-api-gcp.qencode.com/v1/status"
}
Step 4: Check the Status of the Job
Get the status for the job using the /v1/status
API method:
curl --location 'https://api.qencode.com/v1/status' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'task_tokens=YOUR_TASK_TOKEN'
Replace YOUR_TASK_TOKEN
with your actual task token.
The server response will provide the status of the transcoding job:
{
"error": 0,
"statuses": {
"10566ad19601a465801ae56975750123": {
"status": "completed",
"percent": 100,
"error": 0,
...
...
}
}
}
This way, you can get detailed information about the transcoding job including its status, percent completion, and more.