Encoding Job Samples
This document gives you some samples of Encoding job requests. You can send the
following job requests to the Encoding job API which is related to your Axinom
Encoding tenant. As an example, you can send the job request to the encoding API
at https://vip-eu-west-1.axinom.com/
. You can find the descriptions about endpoints
from the Encoding API page.
You can use your storages to pass the input and output content to the Encoding job. In the following examples, we have sample Encoding jobs with AWS and Azure. Read more about storage providers to get an idea about the storage providers you can use.
Encoding Job with AWS
Below, you can find Encoding job requests created using AWS S3 bucket as the storage and AWS SQS as the message publisher. Note that you have to create your own AWS S3 bucket to store your content. You can use the Amazon S3 console, Amazon S3 APIs, AWS CLI, or AWS SDKs to create a bucket. Moreover, you need a SQS target queue to capture the messages related to each event while running the Encoding job. You can use the Amazon SQS console to create standard queues and FIFO queues. Then, you can see the messages in the queue with the message type of each event.
Read more about the need of message queues on the message publishers page.
Below, sample job requests are created under the assumption that your Input and Output are saved into the same S3 bucket, separated by folder.
Simple Encoding Job
This is a simple encoding job request with only the mandatory fields, which need to be supplied to run a successful Encoding job. In this Encoding job request, DRM protection is not used. We’ll assume that the video stored in S3 bucket is a mp4 file with embedded audio. Also, the output is in default bitrates and in the H264 format.
If we assume that the input video is inside the movie/movie_name
folder
inside the S3 bucket, the uriPath should be:
"https://<your_bucket-name>.s3.us-east-2.amazonaws.com/<movie>/<movie_name>/"
{
"ExternalId": "<job_reference_id>",
"ExternalType": "movie",
"ContentAcquisition": {
"Provider": "AmazonS3",
"UriPath": "https://<your_bucket-name>.s3.us-east-2.amazonaws.com/<input-folder-path>/",
"CredentialsName": "PLAINTEXT_AWS_ACCESS_KEY_ID",
"CredentialsSecret": "ENCRYPTED_AWS_SECRET_ACCESS_KEY",
"CredentialsProtection": "Encrypted"
},
"MediaMappings": {
"VideoStreamExpression": "^.*\\.(mp4)$"
},
"ContentProcessing": {
"OutputFormat": ["Cmaf"]
},
"ContentPublishing": {
"Provider": "AmazonS3",
"UriPath": "https://<your_bucket-name>.s3.us-east-2.amazonaws.com/<output-folder-path>/",
"CredentialsName": "PLAINTEXT_AWS_ACCESS_KEY_ID",
"CredentialsSecret": "ENCRYPTED_AWS_SECRET_ACCESS_KEY",
"CredentialsProtection": "Encrypted"
},
"MessagePublishers": [
{
"Type": "AmazonSqs",
"UriPath": "https://sqs.us-east-2.amazonaws.com/<your_account-id>/<your_Queue-path>",
"CredentialsName": "PLAINTEXT_AWS_ACCESS_KEY_ID",
"CredentialsSecret": "ENCRYPTED_AWS_SECRET_ACCESS_KEY",
"CredentialsProtection": "Encrypted"
}
]
}
More Complex Encoding Job
This is a sample encoding job request created using more attributes to access more
features of the Encoding API. We use the "DRMProtection"
attribute for the
Direct Mode. Currently, we are using separate video, audio tracks, and subtitle
files in the Encoding job request.
DRM protection possibilities are described on the DRM Protection page.
You can find lists of pre-defined bitrates for specific aspect ratios under default bitrates and add more ratios to the video representations attributes.
We encourage you to encrypt the AWS credentials as explained under Credentials Protection.
{
"ExternalId": "<job_reference_id>",
"ExternalType": "movie",
"ContentAcquisition": {
"Provider": "AmazonS3",
"UriPath": "https://<your_bucket-name>.s3.us-east-2.amazonaws.com/<input-folder-path>/",
"CredentialsName": "<PLAINTEXT_AWS_ACCESS_KEY_ID>",
"CredentialsSecret": "<ENCRYPTED_AWS_SECRET_ACCESS_KEY>",
"CredentialsProtection": "Encrypted"
},
"MediaMappings": {
"VideoStreamExpression": "^.*\\.(mp4|avi|mov)$",
"AudioFileLanguageExpression": "^audio-([a-zA-Z0-9\\-]+).mp3$",
"SubtitleFileLanguageExpression": "^subtitle-([a-zA-Z0-9\\-]+).(vtt|ttml|srt)$",
"CaptionFileLanguageExpression": "^caption-([a-zA-Z0-9\\-]+).(vtt|ttml|srt)$"
},
"ContentProcessing": {
"OutputFormat": ["Cmaf"],
"VideoFormat": "H264",
"OptimizeFor": "Balance",
"DrmProtection": "CertificateEncryptedBase64Key",
"ContentKey": "<CONTENT_KEY_ENCRYPTED_WITH_ENCODING_SERVICE_CERTIFICATE>",
"KeyID":"<KEY_ID>",
"DeleteFilesFromSourceWhenDone": "False",
"VideoRepresentations": [
{
"Height": 720,
"BitrateInKbps": 1500
},
{
"Height": 480,
"BitrateInKbps": 800
}
]
},
"ContentPublishing": {
"Provider": "AmazonS3",
"UriPath": "https://<your-bucket-name>.s3.us-east-2.amazonaws.com/<output-folder-path>/",
"CredentialsName": "PLAINTEXT_AWS_ACCESS_KEY_ID",
"CredentialsSecret": "ENCRYPTED_AWS_SECRET_ACCESS_KEY",
"CredentialsProtection": "Encrypted"
},
"MessagePublishers": [
{
"Type": "AmazonSqs",
"UriPath": "https://sqs.us-east-2.amazonaws.com/account-id/<your_Queue-name>",
"CredentialsName": "PLAINTEXT_AWS_ACCESS_KEY_ID",
"CredentialsSecret": "ENCRYPTED_AWS_SECRET_ACCESS_KEY",
"CredentialsProtection": "Encrypted"
}
]
}
Encoding Job with Azure
The example below is also the same as the simple AWS example above. Here, we use an Azure storage account to store content and Azure service bus as the message publisher. You can also use the features we mentioned in the AWS advanced example for the example below.
You need your own Azure Storage Account and an Azure Bus service. You can create them using the Azure portal, Azure PowerShell, Azure CLI, or an Azure Resource Manager template.
The endpoint for the message publisher contains the details of the Azure Service Bus. To capture the messages through the Azure Service Bus, you need to create queues for each message type as listed in the events list. Then Axinom Encoding API pushes messages to each queue related to the event.
E.g., for the "JobSuccess"
, you need to create a queue named "jobsuccessqueue"
.
When a "jobsuccess"
event is happening, the messages related to the event are pushed
to the "jobsuccessqueue"
. Learn more about creating Azure Service Bus queues from the
Azure guide.
You can monitor job progress by listening to the queue you created.
{
"ExternalId": "<job_reference_id>",
"ExternalType": "movie",
"ContentAcquisition": {
"Provider": "AzureBlob",
"UriPath": "https://<storage_accout_name>.blob.core.windows.net/<container_name>/<input_folder_path>",
"CredentialsName": "PLAINTEXT_STORAGE_ACCOUNT_NAME",
"CredentialsSecret": "ENCRYPTED_SHARED_KEY",
"CredentialsProtection": "Encrypted"
},
"MediaMappings": {
"VideoStreamExpression": "^.*\\.(mp4)$"
},
"ContentProcessing": {
"OutputFormat": ["Cmaf"]
},
"ContentPublishing": {
"Provider": "AzureBlob",
"UriPath": "https://<storage_accout_name>.blob.core.windows.net/<container_name>/<output_folder_path>",
"CredentialsName": "PLAINTEXT_STORAGE_ACCOUNT_NAME",
"CredentialsSecret": "ENCRYPTED_SHARED_KEY",
"CredentialsProtection": "Encrypted"
},
"MessagePublishers": [
{
"Type": "azureservicebusqueue",
"Connection": "ENCRYPTED_CONNECTION_STRING", // Unencrypted format must be: Endpoint=sb://<azure_service_bus_name>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<your_secret_key>
"CredentialsProtection": "Encrypted"
}
]
}