Documentation
¶
Overview ¶
Package encodingcom provides types and methods for interacting with the Encoding.com API.
You can get more details on the API at http://api.encoding.com/.
Index ¶
- Constants
- type APIError
- type APIStatusResponse
- type AddMediaResponse
- type Client
- func (c *Client) AddMedia(source []string, format []Format, region string) (*AddMediaResponse, error)
- func (c *Client) CancelMedia(mediaID string) (*Response, error)
- func (c *Client) DeletePreset(name string) (*Response, error)
- func (c *Client) GetMediaInfo(mediaID string) (*MediaInfo, error)
- func (c *Client) GetPreset(name string) (*Preset, error)
- func (c *Client) GetStatus(mediaIDs []string, extended bool) ([]StatusResponse, error)
- func (c *Client) ListMedia() (*ListMediaResponse, error)
- func (c *Client) ListPresets(presetType PresetType) (*ListPresetsResponse, error)
- func (c *Client) RestartMedia(mediaID string, withErrors bool) (*Response, error)
- func (c *Client) RestartMediaTask(mediaID string, taskID string) (*Response, error)
- func (c *Client) SavePreset(name string, format Format) (*SavePresetResponse, error)
- func (c *Client) StopMedia(mediaID string) (*Response, error)
- type DestinationStatus
- type Format
- type FormatStatus
- type ListMediaResponse
- type ListMediaResponseItem
- type ListPresetsResponse
- type Logo
- type MediaDateTime
- type MediaInfo
- type Metadata
- type Overlay
- type Preset
- type PresetFormat
- type PresetType
- type Response
- type SavePresetResponse
- type SplitScreen
- type StatusResponse
- type Stream
- type TextOverlay
- type VideoCodecParameters
- type YesNoBoolean
- type ZeroOneBoolean
Constants ¶
const ( // AllPresets is used to retrieve all presets in the response of // ListPresets or GetPreset methods. AllPresets = PresetType("all") // UserPresets is used to retrieve only user-created presets in the // response of ListPresets or GetPreset methods. UserPresets = PresetType("user") // UIPresets is used to retrieve only ui (standard) presets in the // response of ListPresets or GetPreset methods. UIPresets = PresetType("ui") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError represents an error returned by the Encoding.com API.
See http://goo.gl/BzvXZt for more details.
type APIStatusResponse ¶
type APIStatusResponse struct { Status string `json:"status"` StatusCode string `json:"status_code"` Incident string `json:"incident"` }
APIStatusResponse is the response returned by the APIStatus function.
It describes the current status of the Encoding.com API.
func APIStatus ¶
func APIStatus(endpoint string) (*APIStatusResponse, error)
APIStatus queries the current status of the Encoding.com API.
The host parameter is optional, and when omitted, will default to "http://status.encoding.com".
See http://goo.gl/3JKSxy for more details.
func (*APIStatusResponse) OK ¶
func (s *APIStatusResponse) OK() bool
OK returns whether the given status represents no problem in the Encoding.com API.
type AddMediaResponse ¶
type AddMediaResponse struct { Message string `json:"message,omitempty"` MediaID string `json:"mediaid,omitempty"` }
AddMediaResponse represents the response returned by the AddMedia action.
See http://goo.gl/Aqg8lc for more details.
type Client ¶
Client is the basic type for interacting with the API. It provides methods matching the available actions in the API.
func (*Client) AddMedia ¶
func (c *Client) AddMedia(source []string, format []Format, region string) (*AddMediaResponse, error)
AddMedia adds a new media to user's queue.
Format specifies details on how the source files are going to be encoded.
See http://goo.gl/whvHwJ for more details on the source file formatting.
func (*Client) CancelMedia ¶
CancelMedia deletes an existing media on user's queue based on the mediaID.
func (*Client) DeletePreset ¶
DeletePreset delets the given preset from the Encoding.com API.
See http://goo.gl/yrYTn5 for more details.
func (*Client) GetMediaInfo ¶
GetMediaInfo returns video parameters of the specified media when available.
func (*Client) GetPreset ¶
GetPreset returns details about a given preset in the Encoding.com API. It queries both user and UI presets.
See http://goo.gl/6Sdjeb for more details.
func (*Client) GetStatus ¶
func (c *Client) GetStatus(mediaIDs []string, extended bool) ([]StatusResponse, error)
GetStatus returns the status of the given media ids, it returns an slice of StatusResponse, the size of the result slice matches the size of input slice.
func (*Client) ListMedia ¶
func (c *Client) ListMedia() (*ListMediaResponse, error)
ListMedia (GetMediaList action) returns a list of the user's media in the queue.
func (*Client) ListPresets ¶
func (c *Client) ListPresets(presetType PresetType) (*ListPresetsResponse, error)
ListPresets (GetPresetsList action in the Encoding.com API) returns a list of the presets matching the given type.
See http://goo.gl/sugm5F for more details.
func (*Client) RestartMedia ¶
RestartMedia restart the entire job of an existing media on user's queue based on the mediaID. When withErrors enabled it only retry tasks ended with error and not the entire job.
func (*Client) RestartMediaTask ¶
RestartMediaTask restart a specific task on a job.
func (*Client) SavePreset ¶
func (c *Client) SavePreset(name string, format Format) (*SavePresetResponse, error)
SavePreset uses the given name and the given format to create a new preset in the Encoding.com API. The remote API will generate and return the preset name if the name is not provided.
See http://goo.gl/q0xPuh for more details.
type DestinationStatus ¶
DestinationStatus represents the status of a given destination.
type Format ¶
type Format struct { Output []string `json:"output,omitempty"` NoiseReduction string `json:"noise_reduction,omitempty"` OutputPreset string `json:"output_preset,omitempty"` VideoCodec string `json:"video_codec,omitempty"` AudioCodec string `json:"audio_codec,omitempty"` Bitrate string `json:"bitrate,omitempty"` AudioBitrate string `json:"audio_bitrate,omitempty"` AudioChannelsNumber string `json:"audio_channels_number,omitempty"` Framerate string `json:"framerate,omitempty"` FramerateUpperThreshold string `json:"framerate_upper_threshold,omitempty"` Size string `json:"size,omitempty"` FadeIn string `json:"fade_in,omitempty"` FadeOut string `json:"fade_out,omitempty"` AudioSampleRate uint `json:"audio_sample_rate,string,omitempty"` AudioVolume uint `json:"audio_volume,string,omitempty"` CropLeft int `json:"crop_left,string,omitempty"` CropTop int `json:"crop_top,string,omitempty"` CropRight int `json:"crop_right,string,omitempty"` CropBottom int `json:"crop_bottom,string,omitempty"` SetAspectRatio string `json:"set_aspect_ratio,omitempty"` RcInitOccupancy string `json:"rc_init_occupancy,omitempty"` MinRate string `json:"minrate,omitempty"` MaxRate string `json:"maxrate,omitempty"` BufSize string `json:"bufsize,omitempty"` Keyframe []string `json:"keyframe,omitempty"` Start string `json:"start,omitempty"` Duration string `json:"duration,omitempty"` ForceKeyframes string `json:"force_keyframes,omitempty"` Bframes int `json:"bframes,string,omitempty"` Gop string `json:"gop,omitempty"` Metadata *Metadata `json:"metadata,omitempty"` Destination []string `json:"destination,omitempty"` SegmentDuration uint `json:"segment_duration,omitempty"` Logo *Logo `json:"logo,omitempty"` Overlay []Overlay `json:"overlay,omitempty"` TextOverlay []TextOverlay `json:"text_overlay,omitempty"` VideoCodecParameters VideoCodecParameters `json:"video_codec_parameters,omitempty"` Profile string `json:"profile,omitempty"` Rotate string `json:"rotate,omitempty"` SetRotate string `json:"set_rotate,omitempty"` AudioSync string `json:"audio_sync,omitempty"` VideoSync string `json:"video_sync,omitempty"` ForceInterlaced string `json:"force_interlaced,omitempty"` Stream []Stream `json:"stream,omitempty"` AddMeta YesNoBoolean `json:"add_meta,omitempty"` Hint YesNoBoolean `json:"hint,omitempty"` KeepAspectRatio YesNoBoolean `json:"keep_aspect_ratio,omitempty"` StripChapters YesNoBoolean `json:"strip_chapters,omitempty"` TwoPass YesNoBoolean `json:"two_pass,omitempty"` Turbo YesNoBoolean `json:"turbo,omitempty"` TwinTurbo YesNoBoolean `json:"twin_turbo,omitempty"` PackFiles *YesNoBoolean `json:"pack_files,omitempty"` }
Format is the set of options for defining the output format when encoding new media files.
See http://goo.gl/dcE1pF for more details.
type FormatStatus ¶
type FormatStatus struct { ID string Status string CreateDate time.Time StartDate time.Time FinishDate time.Time Description string S3Destination string CFDestination string Size string Bitrate string Output string VideoCodec string AudioCodec string Destinations []DestinationStatus Stream []Stream FileSize string }
FormatStatus is the status of each formatting input for a given MediaID.
It is part of the StatusResponse type.
type ListMediaResponse ¶
type ListMediaResponse struct {
Media []ListMediaResponseItem `json:"media,omitempty"`
}
ListMediaResponse represents the response returned by the GetMediaList action.
See http://goo.gl/xhVV6v for more details.
type ListMediaResponseItem ¶
type ListMediaResponseItem struct { MediaFile string `json:"mediafile,omitempty"` MediaID string `json:"mediaid,omitempty"` MediaStatus string `json:"mediastatus,omitempty"` CreateDate MediaDateTime `json:"createdate,string,omitempty"` StartDate MediaDateTime `json:"startdate,string,omitempty"` FinishDate MediaDateTime `json:"finishdate,string,omitempty"` }
ListMediaResponseItem represents each individual item returned by the GetMediaList action.
See ListMediaResponse
type ListPresetsResponse ¶
type ListPresetsResponse struct { UserPresets []Preset `json:"user"` UIPresets []Preset `json:"ui"` }
ListPresetsResponse represents the response returned by the GetPresetsList action.
See http://goo.gl/sugm5F for more details.
type Logo ¶
type Logo struct { LogoSourceURL string `json:"logo_source,omitempty"` LogoX int `json:"logo_x,string,omitempty"` LogoY int `json:"logo_y,string,omitempty"` LogoMode int `json:"logo_mode,string,omitempty"` LogoThreshold string `json:"logo_threshold,omitempty"` }
Logo is the set of options for watermarking media during encoding, allowing users to add a image to the final media.
See http://goo.gl/4z2Q5S for more details.
type MediaDateTime ¶
MediaDateTime is a custom time struct to be used on Media items
func (*MediaDateTime) UnmarshalJSON ¶
func (mdt *MediaDateTime) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON implementation on MediaDateTime to use dateTimeLayout
type MediaInfo ¶
type MediaInfo struct { Duration time.Duration Bitrate string `json:"bitrate"` VideoCodec string `json:"video_codec"` VideoBitrate string `json:"video_bitrate"` Framerate string `json:"frame_rate"` Size string `json:"size"` PixelAspectRatio string `json:"pixel_aspect_ratio"` DisplayAspectRatio string `json:"display_aspect_ratio"` AudioCodec string `json:"audio_codec"` AudioBitrate string `json:"audio_bitrate"` AudioSampleRate uint `json:"audio_sample_rate,string"` AudioChannels string `json:"audio_channels"` Rotation uint `json:"rotation,string"` }
MediaInfo is the result of the GetMediaInfo method.
See http://goo.gl/OTX0Ua for more details.
type Metadata ¶
type Metadata struct { Title string `json:"title,omitempty"` Copyright string `json:"copyright,omitempty"` Author string `json:"author,omitempty"` Description string `json:"description,omitempty"` Album string `json:"album,omitempty"` }
Metadata represents media metadata, as provided in the Format struct when encoding new media.
See http://goo.gl/jNSio9 for more details.
type Overlay ¶
type Overlay struct { OverlaySource string `json:"overlay_source,omitempty"` OverlayLeft string `json:"overlay_left,omitempty"` OverlayRight string `json:"overlay_right,omitempty"` OverlayTop string `json:"overlay_top,omitempty"` OverlayBottom string `json:"overlay_bottom"` Size string `json:"size,omitempty"` OverlayStart float64 `json:"overlay_start,string,omitempty"` OverlayDuration float64 `json:"overlay_duration,string,omitempty"` }
Overlay is the set of options for adding a video overlay in the media being encoded.
See http://goo.gl/Q6sjkR for more details.
type Preset ¶
type Preset struct { Name string `json:"name"` Type PresetType `json:"type"` Output string `json:"output"` Format PresetFormat `json:"format"` }
Preset represents a preset in the Encoding.com API.
type PresetFormat ¶
type PresetFormat struct { NoiseReduction string `json:"noise_reduction,omitempty"` Output string `json:"output,omitempty"` VideoCodec string `json:"video_codec,omitempty"` AudioCodec string `json:"audio_codec,omitempty"` Bitrate string `json:"bitrate,omitempty"` AudioBitrate string `json:"audio_bitrate,omitempty"` AudioSampleRate uint `json:"audio_sample_rate,string,omitempty"` AudioChannelsNumber string `json:"audio_channels_number,omitempty"` AudioVolume uint `json:"audio_volume,string,omitempty"` Framerate string `json:"framerate,omitempty"` FramerateUpperThreshold string `json:"framerate_upper_threshold,omitempty"` Size string `json:"size,omitempty"` FadeIn string `json:"fade_in,omitempty"` FadeOut string `json:"fade_out,omitempty"` CropLeft int `json:"crop_left,string,omitempty"` CropTop int `json:"crop_top,string,omitempty"` CropRight int `json:"crop_right,string,omitempty"` CropBottom int `json:"crop_bottom,string,omitempty"` SetAspectRatio string `json:"set_aspect_ratio,omitempty"` RcInitOccupancy string `json:"rc_init_occupancy,omitempty"` MinRate string `json:"minrate,omitempty"` MaxRate string `json:"maxrate,omitempty"` BufSize string `json:"bufsize,omitempty"` Keyframe string `json:"keyframe,omitempty"` Start string `json:"start,omitempty"` Duration string `json:"duration,omitempty"` ForceKeyframes string `json:"force_keyframes,omitempty"` Bframes int `json:"bframes,string,omitempty"` Gop string `json:"gop,omitempty"` Metadata *Metadata `json:"metadata,omitempty"` SegmentDuration string `json:"segment_duration,omitempty"` Logo *Logo `json:"logo,omitempty"` VideoCodecParameters interface{} `json:"video_codec_parameters,omitempty"` Profile string `json:"profile,omitempty"` Rotate string `json:"rotate,omitempty"` SetRotate string `json:"set_rotate,omitempty"` AudioSync string `json:"audio_sync,omitempty"` VideoSync string `json:"video_sync,omitempty"` ForceInterlaced string `json:"force_interlaced,omitempty"` KeepAspectRatio YesNoBoolean `json:"keep_aspect_ratio,omitempty"` AddMeta YesNoBoolean `json:"add_meta,omitempty"` Hint YesNoBoolean `json:"hint,omitempty"` TwoPass YesNoBoolean `json:"two_pass,omitempty"` Turbo YesNoBoolean `json:"turbo,omitempty"` TwinTurbo YesNoBoolean `json:"twin_turbo,omitempty"` StripChapters YesNoBoolean `json:"strip_chapters,omitempty"` StreamRawMap interface{} `json:"stream,omitempty"` }
PresetFormat is the set of options for defining the output format in presets.
func (PresetFormat) Stream ¶
func (p PresetFormat) Stream() []Stream
Stream function returns a slice of Advanced HLS stream settings for a preset format.
type PresetType ¶
type PresetType string
PresetType represents the type of preset used as the input of the ListPresets and GetPreset methods.
type Response ¶
type Response struct {
Message string `json:"message,omitempty"`
}
Response represents the generic response in the Encoding.com API. It doesn't include error information, as the client will smartly handle errors and return an instance of APIError when something goes wrong.
See http://goo.gl/GBEn98 for more details.
type SavePresetResponse ¶
type SavePresetResponse struct {
SavedPreset string
}
SavePresetResponse is the response returned in the SavePreset method.
See http://goo.gl/q0xPuh for more details.
type SplitScreen ¶
type SplitScreen struct { Columns int `json:"columns,string,omitempty"` Rows int `json:"rows,string,omitempty"` PaddingLeft int `json:"padding_left,string,omitempty"` PaddingRight int `json:"padding_right,string,omitempty"` PaddingBottom int `json:"padding_bottom,string,omitempty"` PaddingTop int `json:"padding_top,string,omitempty"` }
SplitScreen is the set of options for combining several sources to one split screen video.
See http://goo.gl/EolKyv for more details.
type StatusResponse ¶
type StatusResponse struct { MediaID string UserID string SourceFile string MediaStatus string PreviousMediaStatus string NotifyURL string CreateDate time.Time StartDate time.Time FinishDate time.Time DownloadDate time.Time UploadDate time.Time TimeLeft string Progress float64 TimeLeftCurrentJob string ProgressCurrentJob float64 Formats []FormatStatus }
StatusResponse is the result of the GetStatus method.
See http://goo.gl/NDsN8h for more details.
type Stream ¶
type Stream struct { AudioBitrate string `json:"audio_bitrate,omitempty"` AudioChannelsNumber string `json:"audio_channels_number,omitempty"` AudioCodec string `json:"audio_codec,omitempty"` AudioSampleRate uint `json:"audio_sample_rate,string,omitempty"` AudioVolume uint `json:"audio_volume,string,omitempty"` Bitrate string `json:"bitrate,omitempty"` Deinterlacing string `json:"deinterlacing,omitempty"` DownmixMode string `json:"downmix_mode,omitempty"` DurationPrecision uint `json:"duration_precision,string,omitempty"` Encoder string `json:"encoder,omitempty"` EncryptionMethod string `json:"encryption_method,omitempty"` Framerate uint `json:"framerate,string,omitempty"` Keyframe string `json:"keyframe,omitempty"` MediaPath string `json:"media_path,omitempty"` PixFormat string `json:"pix_format,omitempty"` Profile string `json:"profile,omitempty"` Rotate string `json:"rotate,omitempty"` SetRotate string `json:"set_rotate,omitempty"` Size string `json:"size,omitempty"` StillImageSize string `json:"still_image_size,omitempty"` StillImageTime string `json:"still_image_time,omitempty"` SubPath string `json:"sub_path,omitempty"` VeryFast string `json:"veryfast,omitempty"` VideoCodec string `json:"video_codec,omitempty"` VideoSync string `json:"video_sync,omitempty"` VideoCodecParametersRaw interface{} `json:"video_codec_parameters,omitempty"` AudioOnly YesNoBoolean `json:"audio_only,omitempty"` AddIframeStream YesNoBoolean `json:"add_iframe_stream,omitempty"` ByteRange YesNoBoolean `json:"byte_range,omitempty"` Cbr YesNoBoolean `json:"cbr,omitempty"` CopyNielsenMetadata YesNoBoolean `json:"copy_nielsen_metadata,omitempty"` CopyTimestamps YesNoBoolean `json:"copy_timestamps,omitempty"` Encryption YesNoBoolean `json:"encryption,omitempty"` HardCbr YesNoBoolean `json:"hard_cbr,omitempty"` Hint YesNoBoolean `json:"hint,omitempty"` KeepAspectRatio YesNoBoolean `json:"keep_aspect_ratio,omitempty"` MetadataCopy YesNoBoolean `json:"metadata_copy,omitempty"` StillImage YesNoBoolean `json:"still_image,omitempty"` StripChapters YesNoBoolean `json:"strip_chapters,omitempty"` TwoPass YesNoBoolean `json:"two_pass,omitempty"` VideoOnly YesNoBoolean `json:"video_only,omitempty"` }
Stream is the set of options for defining Advanced HLS stream output when encoding new media files.
See http://goo.gl/I7qRNo for more details.
func (Stream) VideoCodecParameters ¶
func (s Stream) VideoCodecParameters() VideoCodecParameters
VideoCodecParameters function returns settings for H.264 video codec.
type TextOverlay ¶
type TextOverlay struct { Text []string `json:"text,omitempty"` FontSourceURL string `json:"font_source,omitempty"` FontSize uint `json:"font_size,string,omitempty"` FontRotate int `json:"font_rotate,string,omitempty"` FontColor string `json:"font_color,omitempty"` AlignCenter ZeroOneBoolean `json:"align_center,omitempty"` OverlayX int `json:"overlay_x,string,omitempty"` OverlayY int `json:"overlay_y,string,omitempty"` Size string `json:"size,omitempty"` OverlayStart float64 `json:"overlay_start,string,omitempty"` OverlayDuration float64 `json:"overlay_duration,string,omitempty"` }
TextOverlay is the set of options for adding a text overlay in the media being encoded.
See http://goo.gl/gUKi5t for more details.
type VideoCodecParameters ¶
type VideoCodecParameters struct { Coder string `json:"coder,omitempty"` Flags string `json:"flags,omitempty"` Flags2 string `json:"flags2,omitempty"` Cmp string `json:"cmp,omitempty"` Partitions string `json:"partitions,omitempty"` MeMethod string `json:"me_method,omitempty"` Subq string `json:"subq,omitempty"` MeRange string `json:"me_range,omitempty"` KeyIntMin string `json:"keyint_min,omitempty"` ScThreshold string `json:"sc_threshold,omitempty"` Iqfactor string `json:"i_qfactor,omitempty"` Bstrategy string `json:"b_strategy,omitempty"` Qcomp string `json:"qcomp,omitempty"` Qmin string `json:"qmin,omitempty"` Qmax string `json:"qmax,omitempty"` Qdiff string `json:"qdiff,omitempty"` DirectPred string `json:"directpred,omitempty"` Level string `json:"level,omitempty"` Vprofile string `json:"vprofile,omitempty"` }
VideoCodecParameters are settings for H.264 video codec.
See http://goo.gl/8y7VSU for more details.
type YesNoBoolean ¶
type YesNoBoolean bool
YesNoBoolean is a boolean that turns true into "yes" and false into "no" when encoded as JSON.
func (YesNoBoolean) MarshalJSON ¶
func (b YesNoBoolean) MarshalJSON() ([]byte, error)
MarshalJSON is the method that ensures that YesNoBoolean satisfies the json.Marshaler interface.
func (*YesNoBoolean) UnmarshalJSON ¶
func (b *YesNoBoolean) UnmarshalJSON(data []byte) error
UnmarshalJSON is the method that ensure that YesNoBoolean can be converted back from 1 or 0 to a boolean value.
type ZeroOneBoolean ¶
type ZeroOneBoolean bool
ZeroOneBoolean is a boolean that turns true into "1" and false into "0" when encoded as JSON.
func (ZeroOneBoolean) MarshalJSON ¶
func (b ZeroOneBoolean) MarshalJSON() ([]byte, error)
MarshalJSON is the method that ensures that ZeroOneBoolean satisfies the json.Marshaler interface.
func (*ZeroOneBoolean) UnmarshalJSON ¶
func (b *ZeroOneBoolean) UnmarshalJSON(data []byte) error
UnmarshalJSON is the method that ensure that ZeroOneBoolean can be converted back from 1 or 0 to a boolean value.