chunkify

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 14 Imported by: 0

README

Chunkify Logo

Chunkify Go

The official Go library for the Chunkify API.

Requirements

  • Go 1.22 or higher

Installation

You can install the Chunkify Go library using go get:

go get github.com/chunkifydev/chunkify-go

Usage

Creating a Client

First, you'll need to create a client instance to interact with the API. You can create one with default settings or with custom configuration:

import "github.com/chunkifydev/chunkify-go"

// Create a new client instance with default settings
client := chunkify.NewClient("sk_team_key", "sk_project_key")

You can initialize the client with custom configuration:

config := chunkify.Config{
    AccessTokens: chunkify.AccessTokens{
        TeamToken:    "sk_team_token",
        ProjectToken: "sk_project_token",
    },
    Timeout: 60 * time.Second,
}
client = chunkify.NewClientWithConfig(config)
Listing Jobs

The library provides paginated access to your jobs. Here's how to list jobs with filtering and pagination:

// Configure pagination and filtering parameters
params := chunkify.JobListParams{
    Limit:  10,
    Offset: 0,
    Status: chunkify.JobStatusFinished,
}

// Get the first page of results
result, err := client.JobList(params)
if err != nil {
    log.Fatal(err)
}

// Access the current page of jobs
for _, job := range result.Items {
    fmt.Printf("Job ID: %s, Status: %s\n", job.Id, job.Status)
}

// Get the next page
nextPage, err := result.Next()
if err != nil {
    // An error is returned if there is no next page available.
    log.Fatal(err)
}
// Process next page...
Creating a Source

Here is an example of source creation:

// Create a new source
source, err := client.SourceCreate(chunkify.SourceCreateParams{
    Url: "http://somevideos.com/your_source.mp4",
    Metadata: chunkify.SourceCreateParamsMetadata{
        "key": "value",
    },
})

if err != nil {
	t.Fatalf("Error creating source: %v", err)
}

fmt.Printf("New source: %s (%dx%d) with codec %s\n", source.Id, source.Width, source.Height, source.VideoCodec)
Creating Jobs

Here is an example of job creation:

// Create a new job with a custom template
config := &chunkify.FfmpegX264{
    FfmpegVideo: chunkify.FfmpegVideo{
        Height:       1080,
        Framerate:    30,
        VideoBitrate: 5000000, // 5 Mbps
        AudioBitrate: 128000,  // 128 Kbps
    },
}

job, err := client.JobCreate(chunkify.JobCreateParams{
    SourceId: source.Id,
    Format: chunkify.JobCreateFormatParams{
        Name:   chunkify.FormatMp4X264,
        Config: config,
    },
})
Customizing the number of transcoders and CPU

By default, we choose automatically the right number of transcoder with the right CPU. If you want to customize this behavior, you can pass the options like this:

job, err := client.JobCreate(chunkify.JobCreateParams{
    SourceId: source.Id,
    Format: chunkify.JobCreateFormatParams{
        Name:   chunkify.FormatMp4X264,
        Config: config,
    },
    Transcoder: chunkify.JobCreateTranscoderParams{
        Quantity: 10,
        Type: chunkify.TranscoderType8vCPU,
    },
})

Available CPU Resources

The library client automatically tracks the available CPU resources from the API responses. You can access this information through the LastAvailableCpuCount field:

// LastAvailableCpuCount will be -1 (CpuCountUnknown) until the first API response
if client.LastAvailableCpuCount == chunkify.CpuCountUnknown {
    fmt.Println("CPU count not yet available")
} else {
    fmt.Printf("Available CPUs: %d\n", client.LastAvailableCpuCount)
}

Handling Webhooks

To ensure that webhook notifications are coming from Chunkify, you should verify the signature of each request. Here's an example showing how to do it:

// In your webhook handler
func handleWebhook(w http.ResponseWriter, r *http.Request) {
    // Get the signature from the X-Chunkify-Signature header
    signature := r.Header.Get("X-Chunkify-Signature")

    // Read the request body
    body, err := io.ReadAll(r.Body)
    if err != nil {
        http.Error(w, "Error reading request body", http.StatusBadRequest)
        return
    }

    // Verify the signature using your signature key
    if !chunkify.VerifyNotificationSignature(body, signature, "your_signature_key") {
        http.Error(w, "Invalid signature", http.StatusUnauthorized)
        return
    }

    // Parse the webhook payload
    var payload chunkify.NotificationPayload
    if err := json.Unmarshal(body, &payload); err != nil {
        http.Error(w, "Error parsing webhook", http.StatusBadRequest)
        return
    }

    fmt.Println("Received notification", payload.Id, payload.Event)

    switch data := payload.Data.(type) {
	case *chunkify.NotificationPayloadJobCompletedData:
		fmt.Printf("Job %s completed with %d files\n", data.JobId, len(data.Files))
	default:
		fmt.Printf("unexpected payload data type: %T\n", data)
	}
}

Documentation

Index

Constants

View Source
const (

	// TokenScopeTeam represents team-level API operations that require team authentication
	TokenScopeTeam = "team"
	// TokenScopeProject represents project-level API operations that require project authentication
	TokenScopeProject = "project"

	// CpuCountUnknown represents an unknown CPU count before the first request
	CpuCountUnknown = -1
)

Default API endpoint URL

View Source
const (
	// JobStatusQueued indicates the job is waiting to be processed
	JobStatusQueued = "queued"
	// JobStatusProcessing indicates the job is currently being processed
	JobStatusProcessing = "processing"
	// JobStatusDownloading indicates the job is downloading source files
	JobStatusDownloading = "downloading"
	// JobStatusTranscoding indicates the job is actively transcoding media
	JobStatusTranscoding = "transcoding"
	// JobStatusUploading indicates the job is uploading processed files
	JobStatusUploading = "uploading"
	// JobStatusMerging indicates the job is merging processed chunks
	JobStatusMerging = "merging"
	// JobStatusFinished indicates the job has completed successfully
	JobStatusFinished = "finished"
	// JobStatusError indicates the job encountered an error
	JobStatusError = "error"
)

JobStatus constants represent the various states a job can be in during processing

View Source
const (
	// TranscoderType4vCPU represents a transcoder with 4 vCPUs
	TranscoderType4vCPU = "4vCPU"
	// TranscoderType8vCPU represents a transcoder with 8 vCPUs
	TranscoderType8vCPU = "8vCPU"
	// TranscoderType16vCPU represents a transcoder with 16 vCPUs
	TranscoderType16vCPU = "16vCPU"
)

TranscoderType constants represent the available CPU configurations for transcoding

View Source
const (
	// StorageProviderChunkify represents Chunkify's ephemeral storage provider
	// Files are deleted after 24 hours, so not for production use.
	StorageProviderChunkify = "chunkify"
	// StorageProviderAws represents Amazon Web Services (AWS) S3 storage provider
	StorageProviderAws = "aws"
	// StorageProviderCloudflare represents Cloudflare R2 storage provider
	StorageProviderCloudflare = "cloudflare"
)
View Source
const (
	// NotificationEventJobCompleted is the event type sent when a job has finished processing
	NotificationEventJobCompleted = "job.completed"
)

Variables

View Source
var Version = func() string {
	fmt.Println("TEST")
	if info, ok := debug.ReadBuildInfo(); ok {

		for _, dep := range info.Deps {
			if dep.Path == "github.com/chunkifydev/chunkify-go" {

				if strings.Contains(dep.Version, "-0.") {
					return "dev"
				}
				return dep.Version
			}
		}
	}
	return "dev"
}()

Version is the current version of the library, determined at runtime. It returns "dev" for untagged commits or the actual version for tagged releases.

Functions

func VerifyNotificationSignature

func VerifyNotificationSignature(payload []byte, signature string, secret string) bool

VerifyNotificationSignature verifies that a webhook payload was sent by Chunkify. The signature is provided in the X-Chunkify-Signature HTTP header. The secret is the webhook secret configured in the Chunkify dashboard. Returns true if the signature is valid, false otherwise.

Types

type AccessTokens

type AccessTokens struct {
	// ProjectToken is used for project-scoped operations
	ProjectToken string
	// TeamToken is used for team-scoped operations
	TeamToken string
}

AccessTokens contains the authentication keys required for API access. Both project and team level keys can be provided for different operation scopes.

type Client

type Client struct {

	// lastAvailableCpuCount is the last known available cpu count
	// It is initialized to CpuCountUnknown (-1) and will be updated with the actual value
	// from the X-Available-Cpu header in the first authorized response
	LastAvailableCpuCount int64
	// contains filtered or unexported fields
}

Client handles communication with the API. It manages authentication, request execution, and response handling.

func NewClient

func NewClient(teamKey, projectKey string) Client

NewClient creates a new API client with default configuration. It can have both a team key and project key for authentication.

Example:

client := chunkify.NewClient("team_key", "project_key")

func NewClientWithConfig

func NewClientWithConfig(config Config) Client

NewClientWithConfig creates a new API client with custom configuration. This allows overriding default settings like timeout, base URL, and HTTP client.

Example:

config := chunkify.Config{
    APIKeys: chunkify.APIKeys{
        TeamKey:    "team_key",
        ProjectKey: "project_key",
    },
    Timeout: 60 * time.Second,
}
client := chunkify.NewClientWithConfig(config)

func (*Client) FileList

func (c *Client) FileList(params FileListParams) (*PaginatedResult[File], error)

FileList retrieves all files with optional filtering and pagination

func (*Client) Job

func (c *Client) Job(id string) (Job, error)

Job retrieves a single job by its ID. The id parameter specifies the unique identifier of the job to retrieve. Returns the Job object if found, or an error if the request fails.

func (*Client) JobCreate

func (c *Client) JobCreate(params JobCreateParams) (Job, error)

JobCreate creates a new transcoding job with the specified parameters. The params parameter contains the required fields for creating a job. Returns the created Job object, or an error if the request fails.

func (*Client) JobList

func (c *Client) JobList(params JobListParams) (*PaginatedResult[Job], error)

JobList retrieves all jobs with optional filtering and pagination. The params parameter allows filtering and pagination of the results. Returns a paginated list of Job objects, or an error if the request fails.

func (*Client) JobListFiles

func (c *Client) JobListFiles(id string) ([]File, error)

JobListFiles retrieves all files associated with a job. The id parameter specifies the unique identifier of the job. Returns a list of File objects associated with the job, or an error if the request fails.

func (*Client) JobListLogs

func (c *Client) JobListLogs(params JobListLogsParams) ([]Log, error)

JobListLogs retrieves logs for a specific job with optional filtering. The id parameter specifies the unique identifier of the job. The params parameter allows filtering of the log results. Returns a list of Log objects for the job, or an error if the request fails.

func (*Client) Notification

func (c *Client) Notification(id string) (Notification, error)

Notification retrieves a single notification by its ID. The id parameter specifies the unique identifier of the notification to retrieve. Returns the Notification object if found, or an error if the request fails.

func (*Client) NotificationCreate

func (c *Client) NotificationCreate(params NotificationCreateParams) (Notification, error)

NotificationCreate creates a new notification with the specified parameters. The params parameter contains the required fields for creating a notification. Returns the created Notification object, or an error if the request fails.

func (*Client) NotificationList

func (c *Client) NotificationList(params NotificationListParams) (*PaginatedResult[Notification], error)

NotificationList retrieves all notifications with optional filtering and pagination. The params parameter allows filtering and pagination of the results. Returns a paginated list of Notification objects, or an error if the request fails.

func (*Client) Project

func (c *Client) Project(id string) (Project, error)

Project retrieves a single project by its ID. The id parameter specifies the unique identifier of the project to retrieve. Returns the Project object if found, or an error if the request fails.

func (*Client) ProjectCreate

func (c *Client) ProjectCreate(project ProjectCreateParams) (Project, error)

ProjectCreate creates a new project with the specified parameters. The project parameter contains the required fields for creating a project. Returns the created Project object, or an error if the request fails.

func (*Client) ProjectDelete

func (c *Client) ProjectDelete(id string) error

ProjectDelete deletes a project by its ID. The id parameter specifies the unique identifier of the project to delete. Returns an error if the deletion fails.

func (*Client) ProjectList

func (c *Client) ProjectList() ([]Project, error)

ProjectList retrieves a list of all projects. Returns a list of Project objects or an error if the request fails.

func (*Client) ProjectUpdate

func (c *Client) ProjectUpdate(params ProjectUpdateParams) error

ProjectUpdate updates an existing project with the specified parameters. The id parameter specifies the unique identifier of the project to update. The params parameter contains the fields to update. Returns an error if the update fails.

func (*Client) Source

func (c *Client) Source(id string) (Source, error)

Source retrieves a single source by its ID. The id parameter specifies the unique identifier of the source to retrieve. Returns the Source object if found, or an error if the request fails.

func (*Client) SourceCreate

func (c *Client) SourceCreate(params SourceCreateParams) (Source, error)

SourceCreate creates a new source with the specified parameters. The params parameter contains the required fields for creating a source. Returns the created Source object, or an error if the request fails.

func (*Client) SourceList

func (c *Client) SourceList(params SourceListParams) (*PaginatedResult[Source], error)

SourceList retrieves all sources with optional filtering and pagination. The params parameter allows filtering sources by various criteria like size, codec, etc. Returns a paginated list of Source objects and total count, or an error if the request fails.

func (*Client) Storage

func (c *Client) Storage(id string) (Storage, error)

Storage retrieves a single storage by its ID. The id parameter specifies the unique identifier of the storage to retrieve. Returns the Storage object if found, or an error if the request fails.

func (*Client) StorageCreate

func (c *Client) StorageCreate(storage StorageCreateParams) (Storage, error)

StorageCreate creates a new storage configuration. The storage parameter contains the required fields for creating a storage configuration. Returns the created Storage object, or an error if the request fails.

func (*Client) StorageDelete

func (c *Client) StorageDelete(id string) error

StorageDelete deletes a storage configuration by its ID. The id parameter specifies the unique identifier of the storage to delete. Returns an error if the deletion fails.

func (*Client) StorageList

func (c *Client) StorageList() ([]Storage, error)

StorageList retrieves all storages. Returns a list of Storage objects or an error if the request fails.

func (*Client) TokenCreate

func (c *Client) TokenCreate(params TokenCreateParams) (Token, error)

TokenCreate creates a new API token with the specified parameters. The params parameter contains the required fields for creating a token. Returns the created Token object, or an error if the request fails.

func (*Client) TokenList

func (c *Client) TokenList() ([]Token, error)

TokenList retrieves all tokens. Returns a list of Token objects or an error if the request fails.

func (*Client) TokenRevoke

func (c *Client) TokenRevoke(id string) error

TokenRevoke revokes (deletes) an API token by its ID. The id parameter specifies the unique identifier of the token to revoke. Returns an error if the revocation fails.

func (*Client) Webhook

func (c *Client) Webhook(id string) (Webhook, error)

Webhook retrieves a single webhook by its ID. The id parameter specifies the unique identifier of the webhook to retrieve. Returns the Webhook object if found, or an error if the request fails.

func (*Client) WebhookCreate

func (c *Client) WebhookCreate(params WebhookCreateParams) (WebhookWithSecretKey, error)

WebhookCreate creates a new webhook with the specified parameters. The params parameter contains the required fields for creating a webhook. Returns the created Webhook object, or an error if the request fails.

func (*Client) WebhookDelete

func (c *Client) WebhookDelete(id string) error

WebhookDelete deletes a webhook by its ID. The id parameter specifies the unique identifier of the webhook to delete. Returns an error if the deletion fails.

func (*Client) WebhookList

func (c *Client) WebhookList() ([]Webhook, error)

WebhookList retrieves all webhooks. Returns a list of Webhook objects or an error if the request fails.

func (*Client) WebhookUpdate

func (c *Client) WebhookUpdate(params WebhookUpdateParams) error

WebhookUpdate updates an existing webhook with the specified parameters. The params parameter contains the fields to update. Returns an error if the update fails.

type Config

type Config struct {
	// AccessTokens contains both project and team level authentication keys
	AccessTokens AccessTokens
	// Timeout specifies the maximum duration for HTTP requests before timing out
	Timeout time.Duration
	// HTTPClient allows for custom HTTP client implementations
	HTTPClient HTTPClient
	// BaseURL allows overriding the default API endpoint URL
	BaseURL string
}

Config contains all configuration options for the API client. This includes authentication, networking, and endpoint configurations.

type ErrorInfo

type ErrorInfo struct {
	// Type indicates the error category
	Type string `json:"type"`
	// Code is the HTTP status code
	Code int `json:"code"`
	// Message is a human-readable error description
	Message string `json:"message"`

} //	@name	ResponseErrorInfo

ErrorInfo Error response details

@Description	Error response details

type FfmpegAv1

type FfmpegAv1 struct {
	FfmpegCommon
	FfmpegVideo
	Movflags string `json:"movflags,omitempty"`

	// Crf (Constant Rate Factor) controls the quality of the output video.
	// Lower values mean better quality but larger file size. Range: 16 to 63.
	// Recommended values: 18-28 for high quality, 23-28 for good quality, 28-35 for acceptable quality.
	// Example: 23
	Crf int64 `json:"crf,omitempty"`

	// Level specifies the AV1 profile level. Valid values: 30-31 (main), 41 (main10).
	// Higher levels support higher resolutions and bitrates but require more processing power.
	// Example: 41
	Level int64 `json:"level,omitempty"`

	// Profilev specifies the AV1 profile. Valid values:
	// - main: Main profile, good for most applications
	// - main10: Main 10-bit profile, supports 10-bit color
	// - mainstillpicture: Still picture profile, optimized for single images
	// Example: main10
	Profilev string `json:"profilev,omitempty"`

	// Preset specifies the encoding speed preset. Valid values (from fastest to slowest):
	// - 6: Fastest encoding, lowest quality
	// - 7: Very fast encoding, lower quality
	// - 8: Fast encoding, moderate quality
	// - 9: Faster encoding, good quality
	// - 10: Fast encoding, better quality
	// - 11: Balanced preset, good quality
	// - 12: Slower encoding, better quality
	// - 13: Slowest encoding, best quality
	// Example: 10
	Preset string `json:"preset,omitempty"`
}

FfmpegAv1 represents FFmpeg encoding parameters specific to AV1 encoding. @Description FfmpegAv1 represents FFmpeg encoding parameters specific to AV1 encoding.

type FfmpegCommon

type FfmpegCommon struct {
	// Duration specifies the duration to process in seconds.
	// Must be a positive value.
	Duration int64 `json:"duration,omitempty"`

	// Seek specifies the timestamp to start processing from (in seconds).
	// Must be a positive value.
	Seek int64 `json:"seek,omitempty"`
}

FfmpegCommon represents common FFmpeg encoding parameters. @Description FfmpegCommon represents common FFmpeg encoding parameters.

type FfmpegHls

type FfmpegHls struct {

	// HlsTime specifies the duration of each HLS segment in seconds. Range: 1 to 10.
	// Shorter segments provide faster startup but more overhead, longer segments are more efficient.
	// Example: 6
	HlsTime int64 `json:"hls_time,omitempty"`

	// HlsSegmentType specifies the type of HLS segments. Valid values:
	// - mpegts: Traditional MPEG-TS segments, better compatibility
	// - fmp4: Fragmented MP4 segments, better efficiency
	// Example: mpegts
	HlsSegmentType string `json:"hls_segment_type,omitempty"`

	// HlsEnc enables encryption for HLS segments when set to true.
	// Example: false
	HlsEnc bool `json:"hls_enc,omitempty"`

	// HlsEncKey specifies the encryption key for HLS segments. Maximum length: 64 characters.
	// Required when HlsEnc is true.
	// Example: 0123456789abcdef
	HlsEncKey string `json:"hls_enc_key,omitempty"`

	// HlsEncKeyUrl specifies the URL where clients can fetch the encryption key.
	// Required when HlsEnc is true.
	// Example: https://example.com/key
	HlsEncKeyUrl string `json:"hls_enc_key_url,omitempty"`

	// HlsEncIv specifies the initialization vector for encryption. Maximum length: 64 characters.
	// Required when HlsEnc is true.
	// Example: 0123456789abcdef
	HlsEncIv string `json:"hls_enc_iv,omitempty"`
}

FfmpegHls represents FFmpeg encoding parameters specific to HLS (HTTP Live Streaming) output. @Description FfmpegHls represents FFmpeg encoding parameters specific to HLS (HTTP Live Streaming) output. @Description It extends FfmpegX264 with HLS-specific options for streaming and encryption.

type FfmpegHlsAv1

type FfmpegHlsAv1 struct {
	FfmpegHls
	FfmpegAv1
}

FfmpegHlsAv1 represents FFmpeg encoding parameters specific to HLS and AV1 encoding. @Description FfmpegHlsAv1 represents FFmpeg encoding parameters specific to HLS and AV1 encoding.

type FfmpegHlsX264

type FfmpegHlsX264 struct {
	FfmpegHls
	FfmpegX264
}

FfmpegHlsX264 represents FFmpeg encoding parameters specific to HLS and H.264/AVC encoding. @Description FfmpegHlsX264 represents FFmpeg encoding parameters specific to HLS and H.264/AVC encoding.

type FfmpegHlsX265

type FfmpegHlsX265 struct {
	FfmpegHls
	FfmpegX265
}

FfmpegHlsX265 represents FFmpeg encoding parameters specific to HLS and H.265/HEVC encoding. @Description FfmpegHlsX265 represents FFmpeg encoding parameters specific to HLS and H.265/HEVC encoding.

type FfmpegImage

type FfmpegImage struct {
	// Width specifies the output image width in pixels.
	// Must be between -2 and 3840. Use -2 for automatic calculation while maintaining aspect ratio.
	Width int64 `json:"width,omitempty"`

	// Height specifies the output image height in pixels.
	// Must be between -2 and 3840. Use -2 for automatic calculation while maintaining aspect ratio.
	Height int64 `json:"height,omitempty"`

	// Interval specifies the time interval between extracted frames in seconds.
	// Must be a positive value.
	Interval int64 `json:"interval"`

	// Sprite indicates whether to generate a sprite sheet from the extracted frames.
	// When true, combines multiple frames into a single sprite image.
	Sprite bool `json:"sprite,omitempty"`

	// Frames specifies the number of frames to extract.
	// Must be a positive value. Only used when generating sprites.
	Frames int64 `json:"frames,omitempty"`
}

FfmpegImage represents image-specific FFmpeg encoding parameters. @Description FfmpegImage represents image-specific FFmpeg encoding parameters.

type FfmpegJpg

type FfmpegJpg struct {
	FfmpegCommon
	FfmpegImage
}

FfmpegJpg represents FFmpeg encoding parameters specific to JPG encoding. @Description FfmpegJpg represents FFmpeg encoding parameters specific to JPG encoding.

type FfmpegVideo

type FfmpegVideo struct {
	// Width specifies the output video width in pixels.
	// Must be between -2 and 3840. Use -2 for automatic calculation while maintaining aspect ratio.
	Width int64 `json:"width,omitempty"`

	// Height specifies the output video height in pixels.
	// Must be between -2 and 3840. Use -2 for automatic calculation while maintaining aspect ratio.
	Height int64 `json:"height,omitempty"`

	// Framerate specifies the output video frame rate.
	// Must be between 15 and 120 fps.
	Framerate float64 `json:"framerate,omitempty"`

	// Gop specifies the Group of Pictures (GOP) size.
	// Must be between 1 and 60.
	Gop int64 `json:"gop,omitempty"`

	// VideoBitrate specifies the video bitrate in bits per second.
	// Must be between 100Kbps and 50Mbps.
	VideoBitrate int64 `json:"video_bitrate,omitempty"`

	// DisableVideo indicates whether to disable video processing.
	DisableVideo bool `json:"disable_video,omitempty"`

	// AudioBitrate specifies the audio bitrate in bits per second.
	// Must be between 32Kbps and 512Kbps.
	AudioBitrate int64 `json:"audio_bitrate,omitempty"`

	// Channels specifies the number of audio channels.
	// Valid values: 1 (mono), 2 (stereo), 5 (5.1), 7 (7.1)
	Channels int64 `json:"channels,omitempty"`

	// DisableAudio indicates whether to disable audio processing.
	DisableAudio bool `json:"disable_audio,omitempty"`

	// Maxrate specifies the maximum video bitrate in bits per second.
	// Must be between 100Kbps and 50Mbps.
	Maxrate int64 `json:"maxrate,omitempty"`

	// Bufsize specifies the video buffer size in bits.
	// Must be between 100Kbps and 50Mbps.
	Bufsize int64 `json:"bufsize,omitempty"`

	// PixFmt specifies the pixel format.
	// Valid value: yuv420p
	PixFmt string `json:"pixfmt,omitempty"`
}

FfmpegVideo represents video-specific FFmpeg encoding parameters. @Description FfmpegVideo represents video-specific FFmpeg encoding parameters.

type FfmpegVp9

type FfmpegVp9 struct {
	FfmpegCommon
	FfmpegVideo

	// Crf (Constant Rate Factor) controls the quality of the output video.
	// Lower values mean better quality but larger file size. Range: 15 to 35.
	// Recommended values: 18-28 for high quality, 23-28 for good quality, 28-35 for acceptable quality.
	// Example: 23
	Crf int64 `json:"crf,omitempty"`

	// Quality specifies the VP9 encoding quality preset. Valid values:
	// - good: Balanced quality preset, good for most applications
	// - best: Best quality preset, slower encoding
	// - realtime: Fast encoding preset, suitable for live streaming
	// Example: good
	Quality string `json:"quality,omitempty"`

	// CpuUsed specifies the CPU usage level for VP9 encoding. Range: 0 to 8.
	// Lower values mean better quality but slower encoding, higher values mean faster encoding but lower quality.
	// Recommended values: 0-2 for high quality, 2-4 for good quality, 4-6 for balanced, 6-8 for speed
	// Example: 4
	CpuUsed string `json:"cpu_used,omitempty"`
}

FfmpegVp9 represents FFmpeg encoding parameters specific to VP9 encoding. @Description FfmpegVp9 represents FFmpeg encoding parameters specific to VP9 encoding.

type FfmpegX264

type FfmpegX264 struct {
	FfmpegCommon
	FfmpegVideo
	Movflags string `json:"movflags,omitempty"`

	// Crf (Constant Rate Factor) controls the quality of the output video.
	// Lower values mean better quality but larger file size. Range: 16 to 35.
	// Recommended values: 18-28 for high quality, 23-28 for good quality, 28-35 for acceptable quality.
	// Example: 23
	Crf int64 `json:"crf,omitempty"`

	// X264KeyInt specifies the maximum number of frames between keyframes for H.264 encoding.
	// Range: 1 to 120. Higher values can improve compression but may affect seeking.
	// Example: 60
	X264KeyInt int64 `json:"x264_keyint,omitempty"`

	// Level specifies the H.264 profile level. Valid values: 10-13 (baseline), 20-22 (main), 30-32 (high), 40-42 (high), 50-51 (high).
	// Higher levels support higher resolutions and bitrates but require more processing power.
	// Example: 41
	Level int64 `json:"level,omitempty"`

	// Profilev specifies the H.264 profile. Valid values:
	// - baseline: Basic profile, good for mobile devices
	// - main: Main profile, good for most applications
	// - high: High profile, best quality but requires more processing
	// - high10: High 10-bit profile, supports 10-bit color
	// - high422: High 4:2:2 profile, supports 4:2:2 color sampling
	// - high444: High 4:4:4 profile, supports 4:4:4 color sampling
	// Example: high
	Profilev string `json:"profilev,omitempty"`

	// Preset specifies the encoding speed preset. Valid values (from fastest to slowest):
	// - ultrafast: Fastest encoding, lowest quality
	// - superfast: Very fast encoding, lower quality
	// - veryfast: Fast encoding, moderate quality
	// - faster: Faster encoding, good quality
	// - fast: Fast encoding, better quality
	// - medium: Balanced preset, best quality
	// Example: medium
	Preset string `json:"preset,omitempty"`
}

FfmpegX264 represents FFmpeg encoding parameters specific to H.264/AVC encoding. @Description FfmpegX264 represents FFmpeg encoding parameters specific to H.264/AVC encoding. It extends FfmpegCommon with H.264-specific options for quality control and encoding profiles. @Description It extends FfmpegCommon with H.264-specific options for quality control and encoding profiles.

type FfmpegX265

type FfmpegX265 struct {
	FfmpegCommon
	FfmpegVideo
	Movflags string `json:"movflags,omitempty"`

	// Crf (Constant Rate Factor) controls the quality of the output video.
	// Lower values mean better quality but larger file size. Range: 16 to 35.
	// Recommended values: 18-28 for high quality, 23-28 for good quality, 28-35 for acceptable quality.
	// Example: 23
	Crf int64 `json:"crf,omitempty"`

	// X265KeyInt specifies the maximum number of frames between keyframes for H.265 encoding.
	// Range: 1 to 120. Higher values can improve compression but may affect seeking.
	// Example: 60
	X265KeyInt int64 `json:"x265_keyint,omitempty"`

	// Level specifies the H.265 profile level. Valid values: 30-31 (main), 41 (main10).
	// Higher levels support higher resolutions and bitrates but require more processing power.
	// Example: 41
	Level int64 `json:"level,omitempty"`

	// Profilev specifies the H.265 profile. Valid values:
	// - main: Main profile, good for most applications
	// - main10: Main 10-bit profile, supports 10-bit color
	// - mainstillpicture: Still picture profile, optimized for single images
	// Example: main10
	Profilev string `json:"profilev,omitempty"`

	// Preset specifies the encoding speed preset. Valid values (from fastest to slowest):
	// - ultrafast: Fastest encoding, lowest quality
	// - superfast: Very fast encoding, lower quality
	// - veryfast: Fast encoding, moderate quality
	// - faster: Faster encoding, good quality
	// - fast: Fast encoding, better quality
	// - medium: Balanced preset, best quality
	// Example: medium
	Preset string `json:"preset,omitempty"`
}

FfmpegX265 represents FFmpeg encoding parameters specific to H.265/HEVC encoding. It extends FfmpegCommon with H.265-specific options for quality control and encoding profiles. @Description FfmpegX265 represents FFmpeg encoding parameters specific to H.265/HEVC encoding. @Description It extends FfmpegCommon with H.265-specific options for quality control and encoding profiles.

type File

type File struct {
	// Unique identifier of the file
	Id string `json:"id"`
	// ID of the job that created this file
	JobId string `json:"job_id"`
	// Storage identifier where the file is stored
	StorageId string `json:"storage_id"`
	// Path to the file in storage
	Path string `json:"path"`
	// Size of the file in bytes
	Size int64 `json:"size"`
	// MIME type of the file
	MimeType string `json:"mime_type"`
	// Timestamp when the file was created
	CreatedAt time.Time `json:"created_at"`
	// Pre-signed URL to directly access the file (only included when available)
	Url string `json:"url"`

} // @name File

File represents a video or image file generated by a job.

type FileListParams

type FileListParams struct {
	// Offset specifies the starting point for the file listing. Example: 0
	Offset int64 `query:"offset"`

	// Limit specifies the maximum number of files to return. Example: 10
	Limit int64 `query:"limit"`

	// CreatedGte filters files created on or after this date. Example: 2024-01-01T00:00:00Z
	CreatedGte string `query:"created_gte"`

	// CreatedLte filters files created on or before this date. Example: 2024-01-31T23:59:59Z
	CreatedLte string `query:"created_lte"`

	// CreatedSort specifies the order in which to sort the results. Example: desc
	CreatedSort string `query:"created_sort"`

} // @name FileListParams

FileListParams represents the possible parameters for listing files, including pagination and filtering options.

type Format

type Format struct {
	// Name of the transcoding format
	// @Description The format to use for transcoding
	// Example: mp4/x264
	Name string `json:"name"`

	// Configuration parameters for the format
	// @Description A map of configuration values specific to the format
	// For example, for mp4/x264 format this includes parameters like crf, preset, profile etc.
	Config map[string]any `json:"config"`

} // @name JobFormat

Format represents a transcoding format configuration @Description A format defines the transcoding parameters and settings for a job

type FormatConfig

type FormatConfig interface {
	// contains filtered or unexported methods
}

FormatConfig is a marker interface that identifies valid FFmpeg format configurations. Types that implement this interface are considered valid encoding format configurations for FFmpeg operations. The empty formatConfig() method serves as a marker method - it does nothing but ensures only explicitly supported format types can be used.

type FormatName

type FormatName string

FormatName is a string type that represents the name of a format. It is used to identify the format used in a job.

const (
	// FormatMp4X264 represents H.264/AVC video encoding in MP4 container format
	FormatMp4X264 FormatName = "mp4/x264"
	// FormatMp4X265 represents H.265/HEVC video encoding in MP4 container format
	FormatMp4X265 FormatName = "mp4/x265"
	// FormatMp4Av1 represents AV1 video encoding in MP4 container format
	FormatMp4Av1 FormatName = "mp4/av1"
	// FormatWebmVp9 represents VP9 video encoding in WebM container format
	FormatWebmVp9 FormatName = "webm/vp9"
	// FormatHlsX264 represents H.264/AVC video encoding for HLS streaming
	FormatHlsX264 FormatName = "hls/x264"
	// FormatHlsX265 represents H.265/HEVC video encoding for HLS streaming
	FormatHlsX265 FormatName = "hls/x265"
	// FormatHlsAv1 represents AV1 video encoding for HLS streaming
	FormatHlsAv1 FormatName = "hls/av1"
	// FormatJpg represents JPEG image format
	FormatJpg FormatName = "jpg"
)

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient interface defines the required methods from http.Client. This allows for custom HTTP client implementations to be used for testing or special requirements.

type Job

type Job struct {
	// Unique identifier for the job
	// Example: job_2G6MJiNz71bHQGNzGwKx5cJwPFS
	Id string `json:"id"`
	// Current status of the job (e.g., "queued", "ingesting","transcoding", "downloading", "merging", "uploading", "finished", "error")
	// Example: transcoding
	Status string `json:"status"`
	// Progress percentage of the job (0-100)
	// Example: 45.5
	Progress float64 `json:"progress"`
	// Billable time in seconds
	// Example: 120
	BillableTime int64 `json:"billable_time"`
	// ID of the source video being transcoded
	// Example: src_2G6MJiNz71bHQGNzGwKx5cJwPFS
	SourceId string `json:"source_id"`
	// Storage configuration for the job output
	Storage JobStorage `json:"storage"`
	// Creation timestamp
	// Example: 2025-01-01T12:00:00Z
	CreatedAt time.Time `json:"created_at"`
	// Last update timestamp
	// Example: 2025-01-01T12:05:00Z
	UpdatedAt time.Time `json:"updated_at"`
	// When the job started processing
	// Example: 2025-01-01T12:01:00Z
	StartedAt time.Time `json:"started_at"`
	// Transcoder configuration and status
	Transcoder Transcoder `json:"transcoder"`
	// Format configuration used for transcoding
	Format Format `json:"format"`
	// Additional metadata for the job
	Metadata any `json:"metadata"`

	// HlsManifestId is the ID of the HLS manifest for the job
	HlsManifestId *string `json:"hls_manifest_id"`

} // @name Job

Job represents a video transcoding task, including its status, progress, and configuration details

type JobCreateFormatParams

type JobCreateFormatParams struct {
	// This is the format to use for transcoding.
	// FormatName can be one of the following:
	// FormatMp4X264 for mp4/x264
	// FormatMp4X265 for mp4/x265
	// FormatMp4Av1 for mp4/av1
	// FormatWebmVp9 for webm/vp9
	// FormatHlsX264 for hls/x264
	// FormatHlsX265 for hls/x265
	// FormatHlsAv1 for hls/av1
	Name FormatName `json:"name"`

	// Config specifies the encoding parameters based on the version.
	Config FormatConfig `json:"config"`

} //	@name	JobCreateFormatParams

JobCreateFormatParams represents the parameters for creating a job format. It defines the encoding configuration for video/image processing jobs. The format consists of three main components:

1. Name: Specifies the output format (mp4/x264, mp4/x265, hls/x264, hls/x265, webm/vp9, jpg) 2. Config: Contains the actual encoding parameters like resolution, quality settings, etc.

The Config parameters are validated against predefined FFmpeg argument structs based on the format. For example, mp4/x264 format uses FfmpegX264 struct which supports parameters like: - crf (16-35): Controls quality vs file size - preset (ultrafast-medium): Controls encoding speed vs compression - level (10-51): Specifies H.264 profile level - profilev: Sets encoding profile (baseline, main, high) - width/height: Output resolution

type JobCreateParams

type JobCreateParams struct {
	// The ID of the source file to transcode
	// Example: src_UioP9I876hjKlNBH78ILp0mo56t
	SourceId string `json:"source_id"`
	// Optional metadata to attach to the job (max 1024 bytes)
	// Example: key:value,key2:value2
	Metadata JobCreateParamsMetadata `json:"metadata"`
	// Optional storage configuration
	Storage JobCreateStorageParams `json:"storage"`
	// Required format configuration
	Format JobCreateFormatParams `json:"format"`
	// Optional transcoder configuration. If not provided, the system will automatically
	// calculate the optimal quantity and CPU type based on the source file specifications
	// and output requirements. This auto-scaling ensures efficient resource utilization.
	Transcoder JobCreateTranscoderParams `json:"transcoder"`
	// Optional HLS manifest configuration
	// Use the same hls manifest ID to group multiple jobs into a single HLS manifest
	// By default, it's automatically generated if no set for HLS jobs
	// Example:"hls_2v6EIgcNAycdS5g0IUm0TXBjvHV"
	HlsManifestId string `json:"hls_manifest_id"`

} //	@name	JobCreateParams

JobCreateParams represents the parameters for creating a new job, including source file, metadata, storage, format, and transcoder configurations.

type JobCreateParamsMetadata

type JobCreateParamsMetadata map[string]any

JobCreateParamsMetadata is a map of string to any type. It is used to attach additional metadata to a job. The maximum size of the metadata is 1024 bytes.

type JobCreateStorageParams

type JobCreateStorageParams struct {
	// Storage Path specifies a custom storage path where processed files will be stored.
	// Must be a valid file path with max length of 1024 characters.
	// Optional if Storage Id is provided.
	// Example: /path/to/video.mp4
	Path string `json:"path"`

	// Storage Id specifies the storage configuration to use from pre-configured storage options.
	// Must be 4-64 characters long and contain only alphanumeric characters, underscores and hyphens.
	// Optional if Storage Path is provided.
	// Example: aws-my-storage
	Id string `json:"id"`

} //	@name	JobCreateStorageParams

StorageParams defines the storage configuration for job output files. Either Path or Slug must be provided to specify where processed files should be stored. If both are provided, Path takes precedence over Slug.

type JobCreateTranscoderParams

type JobCreateTranscoderParams struct {
	// Quantity specifies the number of transcoder instances to use (1-50).
	// Required if Type is set.
	// Example: 2
	Quantity int64 `json:"quantity"`

	// Type specifies the CPU configuration for each transcoder instance.
	// Required if Quantity is set.
	// Use constants from TranscoderType4vCPU, TranscoderType8vCPU, TranscoderType16vCPU
	Type string `json:"type"`

} //	@name	JobCreateTranscoderParams

JobCreateTranscoderParams defines the configuration for job transcoding resources. If not provided, the system will automatically calculate the optimal quantity and CPU type based on the source file specifications and output requirements. This auto-scaling ensures efficient resource utilization.

type JobListLogsParams

type JobListLogsParams struct {
	// JobId is the unique identifier of the job.
	JobId string `validate:"required" errormsg:"job Id is required"`

	// Service specifies the service type for which logs are requested.
	Service string `query:"service"`

	// TranscoderId is the identifier for the transcoder, required if the service is 'transcoder'.
	TranscoderId int64 `query:"transcoder_id"`

} // @name JobListLogsParams

JobListLogsParams represents the parameters required to retrieve logs for a specific job, including job ID, service type, and optional transcoder ID.

type JobListParams

type JobListParams struct {
	// Id is the unique identifier of the job.
	Id string `query:"id"`

	// Offset specifies the starting point for the job listing.
	Offset int64 `query:"offset"`

	// Limit specifies the maximum number of jobs to return.
	Limit int64 `query:"limit"`

	// SourceId is the unique identifier of the source file associated with the job.
	SourceId string `query:"source_id"`

	// Status filters jobs based on their current status.
	Status string `query:"status"`

	// CreatedGte filters jobs created on or after this date.
	CreatedGte string `query:"created.gte"`

	// CreatedLte filters jobs created on or before this date.
	CreatedLte string `query:"created.lte"`

	// FormatName filters jobs based on the format used.
	FormatName string `query:"format_name"`

	// Metadata allows for additional filtering based on job metadata.
	Metadata [][]string `query:"metadata"`

	// CreatedSort specifies the order in which to sort the results.
	CreatedSort string `query:"created.sort"`

} // @name JobListParams

JobListParams represents the optional parameters for listing jobs

type JobStorage

type JobStorage struct {
	// Name/slug of the storage
	// Example: aws-bucket-slug
	Id string `json:"id"`
	// AWS region for the storage
	// Example: us-east-1
	Region string `json:"region"`
	// Path where the output will be stored
	// Example: path/to/video.mp4
	Path string `json:"path"`

} // @name JobStorage

JobStorage represents the storage configuration for a job @Description Storage settings for where the job output will be saved

type Log

type Log struct {
	// Timestamp when the log was created
	Time time.Time `json:"time"`
	// Log level (e.g. "info", "error", "debug")
	Level string `json:"level"`
	// The log message content
	Msg string `json:"msg"`
	// Name of the service that generated the log
	Service string `json:"service"`
	// Additional structured data attached to the log
	Attributes LogAttrs `json:"attributes"`
	// Optional ID of the job this log is associated with
	JobId string `json:"job_id,omitempty"`

} // @name Log

Log represents a single log entry stored in S3

type LogAttrs

type LogAttrs map[string]any // @name LogAttrs

type Logs

type Logs []Log

type Notification

type Notification struct {
	// Unique identifier of the notification
	// Example: notf_2G6MJiNz71bHQGNzGwKx5cJwPFS
	Id string `json:"id"`
	// ID of the job that triggered this notification
	// Example: job_2G6MJiNz71bHQGNzGwKx5cJwPFS
	JobId string `json:"job_id"`
	// Timestamp when the notification was created
	// Example: 2025-01-01T12:00:00Z
	CreatedAt time.Time `json:"created_at"`
	// JSON payload that was sent to the webhook endpoint
	// Example: {"event":"job.completed","job":{"id":"job_123"}}
	Payload string `json:"payload"`
	// HTTP status code received from the webhook endpoint
	// Example: 200
	ResponseStatusCode int `json:"response_status_code"`
	// Type of event that triggered this notification
	// Example: job.completed
	Event string `json:"event"`
	// Webhook endpoint configuration that received this notification
	Webhook Webhook `json:"webhook"`

} // @name Notification

Notification represents a webhook notification sent to a webhook endpoint

type NotificationCreateParams

type NotificationCreateParams struct {
	// WebhookId specifies the webhook endpoint that will receive the notification.
	// Example: wh_A1cce6120E56e7Tu9ioP09Nhjk9
	WebhookId string `json:"webhook_id"`

	// JobId specifies the job that triggered this notification.
	// Example: job_A1cce6120E56e7Tu9ioP09Nhjk9
	JobId string `json:"job_id"`

	// Event specifies the type of event that triggered the notification.
	// Currently only supports "job.completed" event type.
	// Example: job.completed
	Event string `json:"event"`

} //	@name NotificationCreateParams

NotificationCreateParams represents the parameters required to create a notification, including the webhook ID, job ID, and event type.

type NotificationListParams

type NotificationListParams struct {
	// JobId filters notifications by the unique identifier of the job.
	JobId string `query:"job_id"`

	// WebhookId filters notifications by the unique identifier of the webhook.
	WebhookId string `query:"webhook_id"`

	// Events filters notifications by the type of events.
	Events []string `query:"events"`

	// ResponseStatusCodeEq filters notifications by exact response status code.
	ResponseStatusCodeEq int `query:"response_status_code.eq"`

	// ResponseStatusCodeGte filters notifications by response status code greater than or equal to the specified value.
	ResponseStatusCodeGte int `query:"response_status_code.gte"`

	// ResponseStatusCodeLte filters notifications by response status code less than or equal to the specified value.
	ResponseStatusCodeLte int `query:"response_status_code.lte"`

	// Offset specifies the starting point for the notification listing.
	Offset int64 `query:"offset"`

	// Limit specifies the maximum number of notifications to return.
	Limit int64 `query:"limit"`

	// CreatedGte filters notifications created on or after this date.
	CreatedGte string `query:"created.gte"`

	// CreatedLte filters notifications created on or before this date.
	CreatedLte string `query:"created.lte"`

	// CreatedSort specifies the order in which to sort the results.
	CreatedSort string `query:"created.sort"`

} // @name NotificationListParams

NotificationListParams represents the optional parameters to list notifications, including filtering options such as job ID, webhook ID, events, and creation date.

type NotificationPayload

type NotificationPayload struct {
	// Unique identifier of the notification
	// Example: notf_2G6MJiNz71bHQGNzGwKx5cJwPFS
	Id string `json:"id"`
	// Type of event that triggered the webhook
	// Example: job.completed
	Event string `json:"event"`
	// Timestamp when the event occurred
	// Example: 2023-01-01T12:00:00Z
	Date time.Time `json:"date"`
	// Detailed data associated with the webhook event
	// For job.completed event, Data will be unmarshalled as *NotificationPayloadJobCompletedData
	Data any `json:"data"`

} // @name NotificationPayload

NotificationPayload represents the payload structure sent in webhook notifications

func (*NotificationPayload) UnmarshalJSON

func (p *NotificationPayload) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for NotificationPayload. It handles custom unmarshaling of the notification payload, particularly the Data field which needs to be unmarshaled differently based on the event type.

type NotificationPayloadJobCompletedData

type NotificationPayloadJobCompletedData struct {
	// Unique identifier of the job associated with this webhook event
	// Example: job_2G6MJiNz71bHQGNzGwKx5cJwPFS
	JobId string `json:"job_id"`
	// Additional metadata associated with the event
	// Example: {"key": "value"}
	Metadata any `json:"metadata"`
	// Identifier of the source that triggered this event
	// Example: src_2G6MJiNz71bHQGNzGwKx5cJwPFS
	SourceId string `json:"source_id"`
	// Error message if the job failed, null otherwise
	Error *string `json:"error"`
	// Array of files associated with this webhook event
	Files []File `json:"files"`

} // @name NotificationPayloadJobCompletedData

NotificationPayloadJobCompletedData contains the specific data fields for job.completed event type sent in a webhook payload

type PaginatedResult

type PaginatedResult[T any] struct {
	// Items contains the actual data elements for this page
	Items []T
	// Total represents the total number of items across all pages
	Total int64
	// Offset represents the starting index of the current page
	Offset int64
	// Limit represents the number of items per page
	Limit int64
	// contains filtered or unexported fields
}

PaginatedResult represents a page of results from a paginated API response. It includes both the actual items and metadata about the pagination.

func (*PaginatedResult[T]) HasNext

func (p *PaginatedResult[T]) HasNext() bool

HasNext checks if there is a next page of results available.

func (*PaginatedResult[T]) HasPrevious

func (p *PaginatedResult[T]) HasPrevious() bool

HasPrevious checks if there is a previous page of results available.

func (*PaginatedResult[T]) Next

func (p *PaginatedResult[T]) Next() (*PaginatedResult[T], error)

Next retrieves the next page of results in a paginated response. Returns an error if there is no next page available.

func (*PaginatedResult[T]) Previous

func (p *PaginatedResult[T]) Previous() (*PaginatedResult[T], error)

Previous retrieves the previous page of results in a paginated response. Returns an error if there is no previous page available.

type Project

type Project struct {
	// Unique identifier of the project
	// Example: proj_2uwB5uCiYrtS5jBkHGvKiJ2k8kM
	Id string `json:"id"`
	// Slug is the slug for the project.
	Slug string `json:"slug"`
	// Name of the project
	// Example: My Video Project
	Name string `json:"name"`
	// Timestamp when the project was created
	// Example: 2025-01-01T12:00:00Z
	CreatedAt time.Time `json:"created_at"`
	// Storage identifier where project files are stored
	// Example: stor_aws_2uwB5uCiYrtS5jBkHGvKiJ2k8kM
	StorageId string `json:"storage_id"`

} // @name Project

type ProjectCreateParams

type ProjectCreateParams struct {
	// Name is the name of the project, which must be between 4 and 32 characters.
	// Example: MyProject
	Name string `json:"name"`

} // @name ProjectCreateParams

ProjectCreateParams represents the required parameters for creating a new project.

type ProjectUpdateParams

type ProjectUpdateParams struct {
	// Id is the unique identifier of the project to update.
	// Example: proj_2uwB5uCiYrtS5jBkHGvKiJ2k8kM
	Id string `json:"id"`
	// Name is the new name for the project, which must be between 4 and 32 characters.
	// Example: My Project
	Name string `json:"name"`

	// StorageId specifies the storage configuration for the project, which must be between 4 and 64 characters.
	// Example: stor_aws_2uwB5uCiYrtS5jBkHGvKiJ2k8kM
	StorageId string `json:"storage_id"`

} // @name ProjectUpdateParams

ProjectUpdateParams defines the required and optional parameters for updating a project, including the project slug, name, pause status, and storage configuration.

type RequestSettings

type RequestSettings struct {
	// Method specifies the HTTP method (GET, POST, etc)
	Method string
	// URL is the endpoint path relative to the base URL
	URL string
	// Body contains the request payload for POST/PATCH requests
	Body any
	// QueryString contains URL query parameters for non-paginated requests
	QueryString string
}

RequestSettings contains all parameters needed to execute an API request. This includes the HTTP method, URL, request body, and query parameters.

type ResponseError

type ResponseError struct {
	// Status indicates the response status "error"
	Status string `json:"status"`
	// Error contains error details
	Error ErrorInfo `json:"error"`

} //	@name	ResponseError

ResponseError Error response

@Description	Error response

type ResponseNoContent

type ResponseNoContent struct {

} //	@name	ResponseNoContent

ResponseNoContent No content response

@Description	No content response

type ResponseOk

type ResponseOk struct {
	// Status indicates the response status "success"
	Status string `json:"status"`
	// Data contains the response object
	Data any `json:"data,omitempty"`

} //	@name	ResponseOk

ResponseOk Successful response

@Description	Successful response

type ResponseWithPagination

type ResponseWithPagination struct {
	// Status indicates the response status "success"
	Status string `json:"status"`
	// Data contains the paginated items
	Data any `json:"data"`
	// Total indicates the total number of items
	Total int64 `json:"total"`
	// Offset indicates the starting index of the current page
	Offset int64 `json:"offset"`
	// Limit indicates the number of items per page
	Limit int64 `json:"limit"`

} //	@name	ResponseWithPagination

ResponseWithPagination Paginated response

@Description	Paginated response

type Source

type Source struct {
	// Unique identifier of the source
	Id string `json:"id"`
	// Timestamp when the source was created
	CreatedAt time.Time `json:"created_at"`
	// URL where the source video can be accessed
	Url string `json:"url"`
	// Additional metadata about the source
	Metadata any `json:"metadata"`
	// Device used to record the video
	Device string `json:"device"`
	// Size of the source file in bytes
	Size int64 `json:"size"`
	// Duration of the video in seconds
	Duration int64 `json:"duration"`
	// Width of the video in pixels
	Width int64 `json:"width"`
	// Height of the video in pixels
	Height int64 `json:"height"`
	// Video bitrate in bits per second
	VideoBitrate int64 `json:"video_bitrate"`
	// Video codec used (e.g. h264, h265)
	VideoCodec string `json:"video_codec"`
	// Video framerate in frames per second
	VideoFramerate float64 `json:"video_framerate"`
	// Audio codec used (e.g. aac, mp3)
	AudioCodec string `json:"audio_codec"`
	// Audio bitrate in bits per second
	AudioBitrate int64 `json:"audio_bitrate"`
	// Array of URLs to preview images/thumbnails
	Images []string `json:"images"`

} // @name Source

Source is a video file used as input for a transcoding job

type SourceCreateParams

type SourceCreateParams struct {
	// Url is the URL of the source, which must be a valid HTTP URL.
	Url string `json:"url"`

	// Metadata allows for additional information to be attached to the source, with a maximum size of 1024 bytes.
	Metadata SourceCreateParamsMetadata `json:"metadata"`

} // @name SourceCreateParams

SourceCreateParams represents the parameters for creating a new source.

type SourceCreateParamsMetadata

type SourceCreateParamsMetadata map[string]any

SourceCreateParamsMetadata is a map of string to any type. It is used to attach additional metadata to a source. The maximum size of the metadata is 1024 bytes.

type SourceListParams

type SourceListParams struct {
	// Id filters sources by their unique identifier.
	Id string `query:"id"`

	// Offset specifies the starting point for the source listing.
	Offset int64 `query:"offset"`

	// Limit specifies the maximum number of sources to return.
	Limit int64 `query:"limit"`

	// DurationEq filters sources by exact duration.
	DurationEq float64 `query:"duration.eq"`

	// DurationGte filters sources with a duration greater than or equal to the specified value.
	DurationGte float64 `query:"duration.gte"`

	// DurationGt filters sources with a duration greater than the specified value.
	DurationGt float64 `query:"duration.gt"`

	// DurationLte filters sources with a duration less than or equal to the specified value.
	DurationLte float64 `query:"duration.lte"`

	// DurationLt filters sources with a duration less than the specified value.
	DurationLt float64 `query:"duration.lt"`

	// CreatedGte filters sources created on or after this date.
	CreatedGte string `query:"created.gte"`

	// CreatedLte filters sources created on or before this date.
	CreatedLte string `query:"created.lte"`

	// WidthEq filters sources by exact width.
	WidthEq int64 `query:"width.eq"`

	// WidthGte filters sources with a width greater than or equal to the specified value.
	WidthGte int64 `query:"width.gte"`

	// WidthGt filters sources with a width greater than the specified value.
	WidthGt int64 `query:"width.gt"`

	// WidthLte filters sources with a width less than or equal to the specified value.
	WidthLte int64 `query:"width.lte"`

	// WidthLt filters sources with a width less than the specified value.
	WidthLt int64 `query:"width.lt"`

	// HeightEq filters sources by exact height.
	HeightEq int64 `query:"height.eq"`

	// HeightGte filters sources with a height greater than or equal to the specified value.
	HeightGte int64 `query:"height.gte"`

	// HeightGt filters sources with a height greater than the specified value.
	HeightGt int64 `query:"height.gt"`

	// HeightLte filters sources with a height less than or equal to the specified value.
	HeightLte int64 `query:"height.lte"`

	// HeightLt filters sources with a height less than the specified value.
	HeightLt int64 `query:"height.lt"`

	// SizeEq filters sources by exact size.
	SizeEq int64 `query:"size.eq"`

	// SizeGte filters sources with a size greater than or equal to the specified value.
	SizeGte int64 `query:"size.gte"`

	// SizeGt filters sources with a size greater than the specified value.
	SizeGt int64 `query:"size.gt"`

	// SizeLte filters sources with a size less than or equal to the specified value.
	SizeLte int64 `query:"size.lte"`

	// SizeLt filters sources with a size less than the specified value.
	SizeLt int64 `query:"size.lt"`

	// AudioCodec filters sources by audio codec.
	AudioCodec string `query:"audio_codec"`

	// VideoCodec filters sources by video codec.
	VideoCodec string `query:"video_codec"`

	// Device filters sources by device type (e.g., android or apple).
	Device string `query:"device"`

	// CreatedSort specifies the order in which to sort the results.
	CreatedSort string `query:"created.sort"`

	// Metadata allows for additional filtering based on source metadata.
	Metadata [][]string `query:"metadata"`

} // @name SourceListParams

SourceListParams defines the optional parameters for filtering and paginating the list of sources, including ID, duration, dimensions, creation date, and metadata.

type Storage

type Storage struct {
	// Unique identifier of the storage configuration
	// Example: aws-my-video-bucket
	Id string `json:"id"`
	// Name of the storage provider
	// Example: aws
	Provider string `json:"provider"`
	// Name of the storage bucket
	// Example: my-video-bucket
	Bucket string `json:"bucket"`
	// Geographic region where the storage is located
	// Example: us-east-1
	Region string `json:"region"`
	// Location of the storage bucket
	// Example: US
	Location string `json:"location"`
	// Endpoint of the storage provider
	// Example: https://s3.amazonaws.com
	Endpoint string `json:"endpoint"`
	// Whether the storage bucket is publicly accessible
	// Example: false
	Public bool `json:"public"`
	// Creation timestamp
	// Example: 2021-01-01T00:00:00Z
	CreatedAt time.Time `json:"created_at"`

} // @name Storage

Storage is a storage configuration for a project. Generated files will be uploaded to the storage.

type StorageCreateParams

type StorageCreateParams struct {
	// Bucket is the name of the storage bucket.
	// Example: my-bucket
	Bucket string `json:"bucket"`

	// Endpoint is the URL of the storage endpoint (optional).
	// Example: https://s3.amazonaws.com
	Endpoint string `json:"endpoint"`

	// AccessKeyId is the access key for the storage provider.
	// Example: 1234567890
	AccessKeyId string `json:"access_key_id"`

	// SecretAccessKey is the secret key for the storage provider.
	// Example: 1234567890
	SecretAccessKey string `json:"secret_access_key"`

	// Provider specifies the storage provider (e.g., AWS or Cloudflare).
	// Example: aws
	Provider string `json:"provider"`

	// Region specifies the region of the storage provider.
	// Example: us-east-1
	Region string `json:"region"`

	// Location specifies the geographical location of the storage (optional).
	// Example: US
	Location string `json:"location"`

	// Public indicates whether the storage is publicly accessible.
	// Example: false
	Public bool `json:"public"`

} // @name StorageCreateParams

StorageCreateParams represents the parameters for creating a new storage

type Token

type Token struct {
	// Unique identifier of the token
	// Example: tok_2G6MJiNz71bHQGNzGwKx5cJwPFS
	Id string `json:"id"`
	// Name given to the token
	// Example: Production API Key
	Name string `json:"name"`
	// The actual token value (only returned on creation)
	// Example: jwt-token...
	Token string `json:"token,omitempty"`
	// ID of the project this token belongs to
	// Example: proj_A1cce6120E56e7Tu9ioP09Nhjk9
	ProjectId string `json:"project_id"`
	// Access scope of the token (e.g.project, team)
	// Example: project
	Scope string `json:"scope"`
	// Timestamp when the token was created
	// Example: 2025-01-01T12:00:00Z
	CreatedAt time.Time `json:"created_at"`

} // @name Token

Token is used to authenticate all API requests

type TokenCreateParams

type TokenCreateParams struct {
	// Name is the name of the token, which can be up to 64 characters long.
	// Example: My Token
	Name string `json:"name"`

	// Scope specifies the scope of the token, which must be either "team" or "project".
	// Example: project
	Scope string `json:"scope"`

	// ProjectSlug is required if the scope is set to "project".
	// Example: proj_2uwKEy1KyvrGIfGDzmxXYgacXKn
	ProjectId string `json:"project_id,omitempty"`

} // @name TokenCreateParams

TokenCreateParams represents the parameters for creating a new token. ProjectSlug is required if Scope is set to "project".

type Transcoder

type Transcoder struct {
	// Type of transcoder instance
	// Example: 8vCPU
	Type string `json:"type"`
	// Number of instances allocated
	// Example: 10
	Quantity int64 `json:"quantity"`
	// Transcoding speed multiplier
	// Example: 32.0
	Speed float64 `json:"speed"`
	// Current status of each transcoder instance
	// Example: working,finished,working
	Status []string `json:"status"`

} // @name JobTranscoder

Transcoder represents the transcoder configuration for a job @Description The transcoder configuration for a job

type Webhook

type Webhook struct {
	// Unique identifier of the webhook
	// Example: wh_2G6MJiNz71bHQGNzGwKx5cJwPFS
	Id string `json:"id"`
	// URL where webhook events will be sent
	// Example: https://example.com/webhook
	Url string `json:"url"`
	// ID of the project this webhook belongs to
	// Example: proj_2G6MJiNz71bHQGNzGwKx5cJwPFS
	ProjectId string `json:"project_id"`
	// Whether the webhook is currently enabled
	// Example: true
	Enabled bool `json:"enabled"`
	// Array of event types this webhook subscribes to
	// Example: ["job.completed"]
	Events []string `json:"events"`

} // @name Webhook

Webhook is a webhook configuration for a project. After a job is completed, the webhook will be triggered and the payload will be sent to the webhook url.

type WebhookCreateParams

type WebhookCreateParams struct {
	// Url is the endpoint that will receive webhook notifications, which must be a valid HTTP URL.
	// Example: https://example.com/webhook
	Url string `json:"url"`

	// Events specifies the types of events that will trigger the webhook.
	// Example: job.completed
	Events string `json:"events"`

	// Enabled indicates whether the webhook is active.
	// Example: true
	Enabled bool `json:"enabled"`

} // @name WebhookCreateParams

WebhookCreateParams represents the parameters for creating a new webhook.

type WebhookUpdateParams

type WebhookUpdateParams struct {
	// WebhookId is the unique identifier of the webhook to be updated.
	WebhookId string
	// Enabled indicates whether the webhook should be enabled or disabled.
	// Example: true
	Enabled *bool `json:"enabled"`

} // @name WebhookUpdateParams

WebhookUpdateParams represents the required and optional parameters for updating an existing webhook.

type WebhookWithSecretKey

type WebhookWithSecretKey struct {
	Webhook
	// Secret key used to sign webhook payloads
	// Example: abcdef123456
	SecretKey string `json:"secret_key"`

} // @name WebhookWithSecretKey

WebhookWithSecretKey represents a webhook with its secret key included

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL