Custom transcoding

Updated

Media Broadcast RESTful API reference.

Create a custom transcoding template

Creates a custom transcoding template for the specified entry point.

HTTP request

POST https://api.agora.io/v1/projects/{appid}/fls/entry_points/{entry_point}/settings/transcode/custom?id={name}

Path parameter

ParameterTypeDescription
appidStringRequired. The App ID retrieved from Agora Console.
entry_pointStringRequired. The entry point name.
nameStringRequired. The name of the custom transcoding template. This name must be different from the name of any preset transcoding templates; otherwise, an error occurs.

Request body

The request body is in the JSON Object type, and contains the following fields:

FieldTypeDescription
widthIntegerRequired. The width (pixels) of the video. The value range is [0, 1920], where 0 means to adapt using the original aspect ratio.
heightIntegerRequired. The height (pixels) of the video. The value range is [0,1920], where 0 means to adapt using the original aspect ratio.
videoCodecStringOptional. The video encoding format. Only H.264 is supported. If videoBitrate and profile are specified, this field is required.
videoBitrateIntegerOptional. The video bitrate (bit/s). The value range is [200, 6000].
profileString

Optional. The encoding profile. Each profile represents a set of encoding parameters. Generally speaking, a higher profile means better video quality and requires more resources for encoding and decoding. Possible values include the following:

  • base: The base profile, which is suitable for mobile devices.

  • main: The standard profile, which is suitable for standard-resolution devices.

  • high: The high profile, which is suitable for high-resolution devices.

audioCodecStringOptional. The audio encoding format. Only AAC is supported. If audioBitrate and audioSampleRate are specified, this field is required.
audioBitrateIntegerOptional. The audio bitrate (bit/s). The value range is [100,500].
audioSampleRateIntegerOptional. The audio sampling rate (Hz). Possible values include: 96000, 88200, 64000, 48000, 44100, 32000, and 16000.

HTTP response

If the returned HTTP status code is 200, the request is successful.

If the returned HTTP status code is not 200, the request fails. You can refer to the HTTP status codes for possible reasons.

Example

Request line

POST https://api.agora.io/v1/projects/{your_appid}/fls/entry_points/live/settings/transcode/custom?id={name} HTTP/1.1

Request body

{
    "width": 0,
    "height": 360,
    "videoCodec": "h264",
    "videoBitrate": 1200,
    "profile": "base",
    "audioCodec": "aac",
    "audioBitrate": 320,
    "audioSampleRate": 44100
}

Response line

HTTP/1.1 200 OK

Update a custom transcoding template

Updates the custom transcoding template for the specified entry point.

HTTP request

PATCH https://api.agora.io/v1/projects/{appid}/fls/entry_points/{entry_point}/settings/transcode/custom/{name}

Path parameter

ParameterTypeDescription
appidStringRequired. The App ID retrieved from Agora Console.
entry_pointStringRequired. The entry point name.
nameStringRequired. The name of the custom transcoding template.

Request body

The request body is in the JSON Object type, and contains the following fields:

FieldTypeDescription
widthIntegerOptional. The width (pixels) of the video. The value range is [0, 1920], where 0 means to adapt using the original aspect ratio. If height is specified, this field is required.
heightIntegerOptional. The height (pixels) of the video. The value range is [0,1920], where 0 means to adapt using the original aspect ratio. If width is specified, this field is required.
videoCodecStringOptional. The video encoding format. Only H.264 is supported. If videoBitrate and profile are specified, this field is required.
videoBitrateIntegerOptional. The video bitrate (bit/s). The value range is [200, 6000].
profileString

Optional. The encoding profile. Each profile represents a set of encoding parameters. Generally speaking, a higher profile means better video quality and requires more resources for encoding and decoding. Possible values include the following:

  • base: The base profile, which is suitable for mobile devices.

  • main: The standard profile, which is suitable for standard-resolution devices.

  • high: The high profile, which is suitable for high-resolution devices.

audioCodecStringOptional. The audio encoding format. Only AAC is supported. If audioBitrate and audioSampleRate are specified, this field is required.
audioBitrateIntegerOptional. The audio bitrate (bit/s). The value range is [100,500].
audioSampleRateIntegerOptional. The audio sampling rate (Hz). Possible values include: 96000, 88200, 64000, 48000, 44100, 32000, and 16000.

HTTP response

If the returned HTTP status code is 200, the request is successful.

If the returned HTTP status code is not 200, the request fails. You can refer to the HTTP status codes for possible reasons.

Example

Request line

PATCH https://api.agora.io/v1/projects/{your_appid}/fls/entry_points/live/settings/transcode/custom/{name} HTTP/1.1

Request body

{
    "width": 0,
    "height": 360,
    "videoCodec": "h264",
    "videoBitrate": 1200,
    "profile": "base",
    "audioCodec": "aac",
    "audioBitrate": 320,
    "audioSampleRate": 44100
}

Response line

HTTP/1.1 200 OK

Delete a custom transcoding template

Deletes the custom transcoding template for the specified entry point.

HTTP request

DELETE https://api.agora.io/v1/projects/{appid}/fls/entry_points/{entry_point}/settings/transcode/custom/{name}

Path parameter

ParameterTypeDescription
appidStringRequired. The App ID retrieved from Agora Console.
entry_pointStringRequired. The entry point name.
nameStringRequired. The name of the custom transcoding template.

HTTP response

If the returned HTTP status code is 200, the request is successful.

If the returned HTTP status code is not 200, the request fails. You can refer to the HTTP status codes for possible reasons.

Example

Request line

DELETE https://api.agora.io/v1/projects/{your_appid}/fls/entry_points/live/settings/transcode/custom/{name} HTTP/1.1

Response line

HTTP/1.1 200 OK

List custom transcoding templates

Lists the custom transcoding templates for the specified entry point.

HTTP request

GET https://api.agora.io/v1/projects/{appid}/fls/entry_points/{entry_point}/settings/transcode/custom

Path parameter

ParameterTypeDescription
appidStringRequired. The App ID retrieved from Agora Console.
entry_pointStringRequired. The entry point name.
nameStringRequired. The name of the custom transcoding template.

HTTP response

If the returned HTTP status code is 200, the request is successful. The response body contains the following fields:

  • transcodeList: JSON Array. The list of custom transcoding templates for the entry point. Each custom transcoding template corresponds to a JSON Object and contains the following fields:
FieldTypeDescription
nameStringRequired. The transcoding template name.
widthIntegerRequired. The width of the video.
heightIntegerRequired. The height of the video.
videoCodecStringOptional. The video encoding format. Only H.264 is supported.
videoBitrateIntegerOptional. The video bitrate (bit/s).
profileString

Optional. The encoding profile.

  • base: The base profile, which is suitable for mobile devices.

  • main: The standard profile, which is suitable for standard-resolution devices.

  • high: The high profile, which is suitable for high-resolution devices.

audioCodecStringOptional. The audio encoding format. Only AAC is supported.
audioBitrateIntegerOptional. The audio bitrate (bit/s).
audioSampleRateIntegerOptional. The audio sampling rate (Hz).

If the returned HTTP status code is not 200, the request fails. You can refer to the HTTP status codes for possible reasons.

Example

Request line

GET https://api.agora.io/v1/projects/{your_appid}/fls/entry_points/live/settings/transcode/custom HTTP/1.1

Request body

{
    "transcodeList": [
        {
            "name": "{your_transcode_name}",
            "width": 0,
            "height": 360,
            "videoCodec": "h264",
            "videoBitrate": 1200,
            "profile": "base",
            "audioCodec": "aac",
            "audioBitrate": 320,
            "audioSampleRate": 44100
        }
    ]
}

Response line

HTTP/1.1 200 OK

HTTP status codes

Status codeDescription
200The request succeeds.
400The parameter is invalid, for example the appid or the entry_point is empty, or the region parameter value is invalid.
401Unauthorized (the customer ID and the customer secret do not match).
404The server cannot find the resource according to the request, which means the requested entry point does not exist or the requested URI path is invalid.
500An internal error occurs in the server, so the server is not able to complete the request.
504An internal error occurs in the server. The gateway or the proxy server did not receive a timely request from the remote server.