Encoding.com XML API Guide
The XML API Overview
The communication with the encoding.com is realized through a single interface: by sending HTTP(S) requests to the manage.encoding.com/. All client requests and server answers use XML format. Client must send HTTP(S) POST request with single parameter named xml.
The server response is a normal XML document.
XML format for user’s API request
<query>
<!-- Main fields -->
<userid>[UserID]</userid>
<userkey>[UserKey]</userkey>
<action>[Action]</action>
<mediaid>[MediaID]</mediaid>
<source>[SourceFile]</source>
<notify>[NotifyURL]</notify>
<format>
<!-- Format fields -->
<output>[Output format]</output>
<video_codec>[Video Codec]</video_codec>
<audio_codec>[Audio Codec]</audio_codec>
<bitrate>[Video bitrate]</bitrate>
<audio_bitrate>[Audio bitrate]</audio_bitrate>
<audio_sample_rate>[Audio quality]</audio_sample_rate>
<audio_volume>[Volume]</audio_volume>
<size>[Size]</size>
<crop_left>[Crop Left]</crop_left>
<crop_top>[Crop Top]</crop_top>
<crop_right>[Crop Right]</crop_right>
<crop_bottom>[Crop Bottom]</crop_bottom>
<keep_aspect_ratio>[yes/no]</keep_aspect_ratio>
<thumb_time>[Thumb time]</thumb_time>
<thumb_size>[Thumb size]</thumb_size>
<add_meta>[yes/no]</add_meta>
<rc_init_occupancy>[RC Occupancy]</rc_init_occupancy>
<minrate>[Min Rate]</minrate>
<maxrate>[Max Rate]</maxrate>
<bufsize>[RC Buffer Size]</bufsize>
<keyframe>[Keyframe Period (GOP)]</keyframe>
<start>[Start From]</start>
<duration>[Result Duration]</duration>
<!-- Destination fields -->
<destination>[DestFile]</destination>
<thumb_destination>[Thumb Dest]</thumb_destination>
<!-- Logo fields (OPTIONAL) -->
<logo>
<logo_source>[LogoURL]</logo_source>
<logo_x>[LogoLeft]</logo_x>
<logo_y>[LogoTop]</logo_y>
<logo_mode>[LogoMode]</logo_mode>
<logo_threshold>[LogoTreshold]</logo_threshold>
</logo>
<!-- Video codec parameters (OPTIONAL, while only for libx264 video codec) -->
<video_codec_parameters>
To see the example for parameters please follow this link below *
</video_codec_parameters>
<!-- Profile (OPTIONAL, while only for libx264 video codec) -->
<pofile>[high/main/baseline]</pofile>
<!-- Turbo Encoding switch (OPTIONAL) -->
<turbo>[yes/no]</turbo>
</format>
</query>
* - Video codec settings
Fields values
Main fields
- UserID – an unique user identifier. Can be taken from user’s page.
- UserKey – user’s key string. Creates automatically when user created and can be changed by user.
- Action – the action to be performed.
- AddMedia – add new media to user’s media list, creates new items in a queue according to formats specified in XML
- AddMediaBenchmark - add new media to user's media list and set a flag for NOT processing it after downloading. Format fields could be specified as well. If NotifyURL is set, a notification will be sent after the media will have been ready for processing.
Note: The media will get 'Ready to process' status only if at least one <format> was specified.
- UpdateMedia – replace information about existing media's formats. All old format items will be deleted, and the new ones added.
- ProcessMedia - start encoding of previously downloaded media (one that added with AddMediaBenchmark action)
- CancelMedia – delete specified media and all its items in queue
- GetMediaList – return list of user’s media
- GetStatus – return information about selected user’s media and all its items in queue
- GetMediaInfo - returns some video parameters of the specified media, if available
- MediaID – an unique identifier of media. This field must be specified for the following actions: UpdateMedia, CancelMedia, GetStatus.
- SourceFile – media source file. It can be in the following formats: http://[user[:password]@]hostname[:port]/[path]/[filename] or ftp://[user[:password]@]hostname[:port]/[path]/[filename] or sftp://[user[:password]@]hostname[:port]/[path]/[filename] or http://[AWS_KEY:AWS_PWD@][bucket].s3.amazonaws.com/[filename] – If you need your S3 files to be accessed with your own AWS credentials, add your AWS key/secret to the URL. Note: do not forget to encode your AWS_SECRET, specifically replace '/ ' with '%2F'. If you don't specify AWS key/secret, the object must have READ permission for AWS user 1a85ad8fea02b4d948b962948f69972a72da6bed800a7e9ca7d0b43dc61d5869 (or for all users). See http://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_ACLs.html#S3_ACLs_Grantees for details. Or http://RS_USER:RS_KEY@storage.cloudfiles.com/your_folder/file.ext or https://storage4.clouddrive.com/v1/MossoCloudFS_cea19775-aa94-4d78-8da9-1a7b4bbbd548/your_folder/file.ext?auth-token=c2633419-7b79-3d58-8417-d63666dddfd5
This field must be specified only for AddMedia and AddMediaBenchmark actions.
- NotifyURL – could be either an HTTP(S) URL of the script the result would be posted to, or a mailto: link with email address the result info to be sent. This field may be specified for AddMedia and AddMediaBenchmark actions.
Format fields
One or more <format> elements required for AddMedia and UpdateMedia actions.They may contain the following child elements:
flv, fl9, wmv, 3gp, mp4, m4v, ipod, iphone, appletv, psp, zune, mp3, wma, m4a, thumbnail*, image **, mpeg2 ***, iphone_stream ****.
Default: none
* - see Thumbnail Features below
** - see Image Converting Features below
3gp: 128x96, 176x144, 352x288, 704x576, 1408x1152
appletv: 710x480
zune: 320x180, 320x240
vp6: WxH, where W and N are multiple of 16
3gp: 176x144
iphone: 480x368
appletv: 710x480
psp: 368x192
zune: 320x180
3gp: 256k
ipod, iphone, psp: 1024k
psp: 30000/1001
fl9: libx264
wmv, zune: wmv2, msmpeg4
3gp: h263, libx264
m4v: mpeg4
mp4, ipod, iphone, appletv, psp: mpeg4, libx264
mp3, wma: none
mpeg2: mpeg2video
fl9: libx264
wmv, zune: wmv2
3gp: h263
mp4, m4v, ipod, iphone, appletv, psp: mpeg4
mpeg2: mpeg2video
3gp: 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k, 12.2k
flv, wmv, mp3, wma, zune: 32k, 40k, 48k, 56k, 64k, 80k, 96k, 112k, 128k, 144k, 160k, 192k, 224k, 256k, 320k
3gp: 12.2k
ipod, iphone, psp: 128k
3gp: 8000
flv, mp3: 11025, 22050, 44100
wmv, wma, zune: 11025, 22050, 32000, 44100, 48000
mpeg2: 44100, 48000
3gp: 8000
flv, mp3, zune, mpeg2: 44100
m4a: libfaac
flv: libmp3lame, libfaac
fl9, mp4, m4v, ipod, iphone, appletv, psp: libfaac
wmv, wma, zune: wmav2, libmp3lame
3gp: libamr_nb
mpeg2: pcm_s16be, pcm_s16le
fl9, mp4, m4v, ipod, iphone, appletv, psp: libfaac
wmv, zune: wmav2
3gp: libamr_nb
mpeg2: pcm_s16be
m4a: libfaac
3gp: 1
3gp: 1
flv: no
Destination fields
sftp://[user[:password]@]hostname[:port]/[path]/[filename],
http://[AWS_KEY:AWS_SECRET@][bucket].s3.amazonaws.com/[filename][?acl=public-read | authenticated-read] - If you need your S3 files to be accessed with your own AWS credentials, add your AWS key/secret to the URL.
If you use the Access key and Secret key they must be urlencode. Let the Key and the Secret are:
1ZG3YAKJ8W0VOA9L7WT6,
lQT5MsQLirc8owb:SxX/9EhU4M+QarasFelQ0v2M
First, we must urlencode the Secret as it contains special URL's characters: ':','+' and '/'. The encoded Secret is:
lQT5MsQLirc8owb%3ASxX%2F9EhU4M%2BQarasFelQ0v2M
We should not encode the colon between Key and Secret nor the '@' after them.
So, the destination URL will be:
Note: do not forget to encode your AWS_SECRET, specifically replace '/ ' with '%2F'.
If you don't specify AWS key/secret, the bucket must have READ and WRITE permissions for AWS user 1a85ad8fea02b4d948b962948f69972a72da6bed800a7e9ca7d0b43dc61d5869, See http://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_ACLs.html#S3_ACLs_Grantees for details.
Also, you can add ?acl=public-read OR ?acl=authenticated-read after the filename. This will explicitly set access rights to the saved object instead of the default settings.
http://[AWS_KEY:AWS_SECRET@][bucket].s3.amazonaws.com/[filename]
Logo fields
ftp://[user[:password]@]hostname[:port]/[path]/[filename][?passive=yes],
sftp://[user[:password]@]hostname[:port]/[path]/[filename],
How mode and threshold work
logo_mode 0: The watermark picture works like this (assuming color intensities 0..0xFF): Per color do this (assuming logo_threshold is '808080'): If mask color is 0x80, no change to the original frame. If mask color is < 0x80 the absolute difference is subtracted from the frame. If result < 0, result = 0. If mask color is > 0x80 the absolute difference is added to the frame. If result > 0xFF, result = 0xFF.If threshold is 000000 the color value of watermark is added to the destination.
logo_mode 1: Per color do this: If mask color > threshold color then the watermark pixel is used.
Advanced H.264 Parameters
Profile option
mp4, mv4: main
ipod, iphone, _3gp, appletv, psp: baseline
Turbo Encoding option
NOTE: Additional encoding bandwidth charges apply, see the Turbo Encoding Help Article for more details.
VP6 Features
If you choose 'vp6' codec for 'flv' output format, your XML query will differ (less number of parameters are supported, see below):
<output>flv</output>
<video_codec>vp6</video_codec>
<bitrate></bitrate> <!-- optional -->
<size></size> <!-- optional -->
<audio_bitrate>64k</audio_bitrate> <!-- optional -->
<audio_sample_rate>44100</audio_sample_rate> <!-- optional -->
<audio_channels_number>2</audio_channels_number> <!-- optional -->
<framerate></framerate> <!-- optional -->
<destination></destination> <!-- optional -->
</format>
Note: It is strongly recommended to use video dimensions that are multiple of 16.
Note: old-style requests with <output>vp6</output> are deprecated and will be automatically converted to the new form. <profile> parameter will be ignored at all.
Thumbnail Features
Instead of using deprecated thumb_* parameters within <format>, you can specify separate encoding task with output = thumbnail:
<!-- Format fields -->
<output>thumbnail</output>
<time>[Time]</time>
<width>[Width]</width>
<height>[Size]</height>
<!-- Destination fields -->
<destination>[DestFile]</destination>
</format>
With the following specific parameters:
If you specify only one parameter from this pair, the other one will be calculated according to your video size.
If none of those parameters specified, the thumbnail will have the same size as your video has.
Now only JPEG format is supported for thumbnails.
Note: old-style requests with elements are deprecated and will be automatically converted to the new form.
Image Features
<!-- Format fields -->
<output>image</output>
<image_format>jpg</image_format>
<resize_method>resize</resize_method>
<size>560x420</size>
<keep_aspect_ratio>yes</keep_aspect_ratio>
<quality>75</quality>
<sharpen_radius>1</sharpen_radius>
<sharpen_sigma>0.5</sharpen_sigma>
<remove_metadata>no</remove_metadata>
<!-- Destination fields -->
<destination>[DestFile]</destination>
</format>
With the following specific parameters:
All: none
sharpen_radius [optional] - Sharpen radius (use 0 in most cases)
sharpen_sigma [optional] - Sharpen amount (best are 0.5-1.0)
iPhone Streaming Features
<!-- Format fields -->
<output>iphone_stream</output>
<bitrates>[CommaSeparatedList]</bitrates>
<segment_duration>[Duration]</segment_duration>
<pack_files>[yes|no]</pack_files>
<!-- Destination fields -->
<destination>[DestFile]</destination> <!-- optional -->
</format>
With the following specific parameters:
Server Response XML format
The response for API request can vary depending on action:
AddMedia action
<response>
<message>Added</message>
<MediaID>[MediaID]</MediaID>
</response>
GetMediaList action
<response>
<media>
<mediafile>[""SourceFile""]</mediafile>
<mediaid>[""MediaID""]</mediaid>
<mediastatus>Closed</mediastatus>
<createdate>[Date]</createdate>
<startdate>[Date]</startdate>
<finishdate>[Date]</finishdate>
</media>
<media>
...
</media>
</response>
Where Date is of the format: YYYY-MM-DD HH:MM:SS
GetMediaList action
<response>
<media>
<mediafile>[""SourceFile""]</mediafile>
<mediaid>[""MediaID""]</mediaid>
<mediastatus>Closed</mediastatus>
<createdate>[Date]</createdate>
<startdate>[Date]</startdate>
<finishdate>[Date]</finishdate>
</media>
<media>
...
</media>
</response>
Where Date is of the format: YYYY-MM-DD HH:MM:SS
GetStatus action
Simple mode
<response>
<id>[MediaID]</id>
<userid>[UserID]</userid>
<sourcefile>[SourceFile]</sourcefile>
<status>[MediaStatus]</status>
<notifyurl>[NotifyURL]</notifyurl>
<created>[Date]</created>
<started>[Date]</started>
<finished>[Date]</finished>
<prevstatus>[MediaStatus]</prevstatus>
<downloaded>[Date]</downloaded>
<uploaded>[Date]</uploaded>
<time_left>[TotalTimeLeft]</time_left>
<progress>[TotalProgress]</progress>
<time_left_current>[StatusTimeLeft]</time_left_current>
<progress_current>[StatusProgress]</progress_current>
<format>
<id>[ID]</id>
<status>[Status]</status>
<created>[Date]</created>
<started>[Date]</started>
<finished>[Date]</finished>
[FormatFields]
<s3_destination>[TempS3Link]</s3_destination> <!-- optional -->
<cf_destination>[TempCFLink]</cf_destination> <!-- optional -->
</format>
<format>
…
</format>
</response>
Where Date is of the format: YYYY-MM-DD HH:MM:SS
FormatFields is a set of fields corresponding to <format> section of an user’s API request
TotalTimeLeft is an estimated time until the media processing would be finished
StatusTimeLeft is an estimated time left for the media's current status
TotalProgress is an estimated progress for entire media processing (in percent)
StatusProgress is an estimated progress for the media's current status (in percent)
TempS3Link S3 URL of the encoded file, if the <destination> was empty and result put to S3
TempCFLink CDN URL of the encoded file, if the <destination> was empty and result put to Rackspace CloudFiles
MediaStatus can take the following values: 'New', 'Downloading', 'Ready to process', 'Waiting for encoder', 'Processing', 'Saving', 'Finished', 'Error'.
Status can take the following values: 'New', 'Waiting for encoder', 'Processing', 'Saving', 'Finished', 'Error'.
Extended (batch) mode
to request the status of several medias in one request:
Request:
<action>GetStatus</action>
<userid>[UserID]</userid>
<userkey>[UserKey]</userkey>
<extended>yes</extended>
<mediaid>[CommaSeparatedList]</mediaid>
</query>
Response:
<job>
<id>[MediaID]</id>
<userid>[UserID]</userid>
<sourcefile>[SourceFile]</sourcefile>
<status>[MediaStatus]</status>
<notifyurl>[NotifyURL]</notifyurl>
<created>[Date]</created>
<started>[Date]</started>
<finished>[Date]</finished>
<prevstatus>[MediaStatus]</prevstatus>
<downloaded>[Date]</downloaded>
<filesize>[FileSize]</filesize>
<processor>[AMAZON | RACKSPACE]</processor>
<progress>[TotalProgress]</progress>
<time_left>[TotalTimeLeft]</time_left>
<format>
<id>[ID]</id>
<status>[Status]</status>
<created>[Date]</created>
<started>[Date]</started>
<finished>[Date]</finished>
<s3_destination>[TempS3Link]</s3_destination> <!-- optional -->
<cf_destination>[TempCFLink]</cf_destination> <!-- optional -->
<convertedsize>[FileSize]</convertedsize>
<time_left>[TotalTimeLeft]</time_left>
<progress>[TotalProgress]</progress>
<time_left_current>[StatusTimeLeft]</time_left_current>
<progress_current>[StatusPorgress]</progress_current>
<file_size>[FileSize]</file_size>
</format>
<format>
…
</format>
</job>
<job>
...
</job>
...
</response>
GetMediaInfo action
<response>
<bitrate>1807k</bitrate>
<duration>6464.83</duration>
<video_codec>mpeg4</video_codec>
<video_bitrate>1679k</video_bitrate>
<frame_rate>23.98</frame_rate>
<size>640x352</size>
<pixel_aspect_ratio>1:1</pixel_aspect_ratio>
<display_aspect_ratio>20:11</display_aspect_ratio>
<audio_codec>ac3</audio_codec>
<audio_sample_rate>48000</audio_sample_rate>
<audio_channels>2</audio_channels>
</response>
Parameters description:
duration – tracks duration in seconds.
pixel_aspect_ratio – Pixel's rectangle width/height ratio (1:1 = square pixel).
display_aspect_ratio – Video frame's width/height ratio.
audio_channels – number of audio channels (commonly 1, 2 or 5.1).
Note: for each particular media some parameters can be omited.
Other actions
<response>
<!-- Message section -->
<message>[Message]</message>
<!-- Errors section -->
<errors>
<error>[Error]</error>
<error>[Error]</error>
…
</errors>
</response>
Error Messages
Error Messages appears in the response if the action was failed.
Common Errors
Wrong XML - The XML query provided in the request is not well-formed
Wrong query format - The XML does not contain <query> root element
Invalid action - The Action parameter is empty or has not in the list of allowed actions
Authentication Errors
Source Media Handling Errors
Queue Handling Errors
Encoding Result XML format
If " http(s):// " link is specified in the <notify> part of the <query>, HTTP POST request will be sent to the specified location. The POST data will contain one parameter named xml, containing XML of the following format:
<result>
<mediaid>[MediaID]</mediaid>
<source>[SourceFile]</source>
<status>[MediaStatus]</status>
<description>[ ErrorDescription]</description> <!-- Only in case of Status = Error -->
<format>
<output>[OutputFormat]</output>
<destination>[DestFile]</destination> <!-- Only in case of Status = Finished -->
<status>[TaskStatus]</status>
<description>[ErrorDescription]</description> <!-- Only in case of Status = Error -->
<suggestion>[ErrorSuggestion]</suggestion> <!-- Only in case of Status = Error -->
</format>
</result>
Fields values
- MediaID - an unique identifier of the media.
- SourceFile - media source file URL
- MediaStatus - could be either Finished or Error
- OutputFormat - format of encoded file, as was requested in the query.
- DestFile, ThumbDest - could be one of the following:
ftp://[user]:[password]@[server]/[path]/[filename],
http://[users.bucket].s3.amazonaws.com/[path]/[filename] (the bucket must have WRITE permission for AWS user 1a85ad8fea02b4d948b962948f69972a72da6bed800a7e9ca7d0b43dc61d5869, See http://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_ACLs.html#S3_ACLs_Grantees for details) , OR
http://[encoding.bucket].s3.amazonaws.com/[path]/[filename] - if destination was not specified in the query.
- TaskStatus - could be either Finished or Error
- ErrorDescription - the description of the error if status is Error
- ErrorSuggestion - the description of the error if status is Error and we have any suggestion available for this error.











