-
Notifications
You must be signed in to change notification settings - Fork 72
How to Integrate with the Video Transcoding API?
This document aims to describe the steps to integrate a transcoding provider with the Video Transcoding API. In a high level, an encoding provider should be able to store Presets and run encoding Jobs.
func (t *TranscodingProvider) CreatePreset(db.Preset) (string, error)
A Preset consists of a set of configurations such as codec, resolution, bitrate, GOP size and others. The Transcoding API will be responsible to call the CreatePreset()
method and map the presetID
returned by the call in an internal PresetMap so the same Preset can be reused across all providers.
Alternatively, if your encoding provider doesn't support the creation and handling of presets, you can use the API's LocalPreset
which leverages our internal database to save them. For an example on how to do it, you can checkout Zencoder integration.
You can check the presets being used at The New York Times.
Delete the preset on the provider.
Returns a interface{} with the provider's preset.
This is the main function for the integration. When triggering a new job, the Transcoding API will call this function with a set of outputs (which is basically a map of output filename and the preset to be applied to the given output). In case that one or more of the outputs is ABR, the StreamingParams
struct will be filled with some details such as SegmentDuration
and PlaylistFilename
. Make sure to pass hls
or dash
on the Protocol
field.
Every time that a client makes GET /jobs/JobID
, the Transcoding API will call this method. The JobStatus
struct contains information such as the Progress
and State
of the job. There's also a ProviderStatus
field that can be filled with any details related to the provider.
Cancel the job on the provider.
Healthcheck should return nil if the provider is currently available for transcoding videos, otherwise, it should return an error explaining what's going on.
Capabilities describes the available features in the provider. It defines which input and output formats/codecs/containers the provider supports, along with supported destinations (s3, ftp, etc).
Here are the most important structs for the integration. You can always look at the types file and provider structs.
type Job struct {
ID string `redis-hash:"jobID" json:"jobId"`
ProviderName string `redis-hash:"providerName" json:"providerName"`
ProviderJobID string `redis-hash:"providerJobID" json:"providerJobId"`
StreamingParams StreamingParams `redis-hash:"streamingparams,expand" json:"streamingParams,omitempty"`
CreationTime time.Time `redis-hash:"creationTime" json:"creationTime"`
SourceMedia string `redis-hash:"source" json:"source"`
Outputs []TranscodeOutput `redis-hash:"-" json:"outputs"`
}
This struct is used when the Job has HLS outputs.
type StreamingParams struct {
SegmentDuration uint `redis-hash:"segmentDuration" json:"segmentDuration"`
Protocol string `redis-hash:"protocol" json:"protocol"`
PlaylistFileName string `redis-hash:"playlistFileName" json:"playlistFileName,omitempty"`
}
TranscodeOutput represents a transcoding output. It's a combination of the preset and the output file name.
type TranscodeOutput struct {
Preset PresetMap `redis-hash:"presetmap,expand" json:"presetmap"`
FileName string `redis-hash:"filename" json:"filename"`
type JobStatus struct {
ProviderJobID string `json:"providerJobId,omitempty"`
Status Status `json:"status,omitempty"`
ProviderName string `json:"providerName,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
Progress float64 `json:"progress"`
ProviderStatus map[string]interface{} `json:"providerStatus,omitempty"`
Output JobOutput `json:"output"`
SourceInfo SourceInfo `json:"sourceInfo,omitempty"`
}