As detailed as we can possibly be. As flexible as ever.
EncodeMagic implements a config-based API which is built with simplicity and flexibility in mind.
A single configuration file is used to describe your entire encoding workflow from transcoding to multiple formats to generating thumbnails of any size and transforming Powerpoint presentations to videos. It is all then submitted to EncodeMagic for processing. So simple.
EncodeMagic implements a config-based API which is built with simplicity and flexibility in mind.
A single configuration file is used to describe your entire encoding workflow from transcoding to multiple formats to generating thumbnails of any size and transforming Powerpoint presentations to videos. It is all then submitted to EncodeMagic for processing. So simple.
To create a conversion task, you just need to make a single HTTP (POST) request to the following URL:
http://api.encodemagic.com/v1/tasks
Tasks need to be authenticated with an API key using Basic Auth. The username is always EM-API-Key
and the password should be a valid API key.
The HTTP request is a regular POST
request which uses a json file to describe the task at hand:
curl -s -v -u EM-API-Key:PRIVATE_KEY -H "Accept: application/json" -H "Content-type: application/json" -X POST --data @mytask.json http://api.rs.encodemagic.com:80/v1/tasks/
After a job is successfully submitted, you will receive an HTTP 200
response and the following message:
{"Task": "803sldjfa-c7e0sd-1ds1e4-a3wf6-421aa90e079f"}
This is the Task ID
. Capturing it allows us to poll the system for task status and progress.
Should there be any errors with the task, EncodeMagic will instead return an HTTP 406
response along with a short message describing the problem, whenever possible.
Now, assuming all went well we can send a regular GET
request to retrieve the status of a particular task:
curl -s -v -u EM-API-Key:PRIVATE_KEY http://api.rs.encodemagic.com:80/v1/tasks/803sldjfa-c7e0sd-1ds1e4-a3wf6-421aa90e079f
If the task in question is in progress and has not yet completed then we should receive something among the following lines:
HTTP 200 OK
Content-Type: application/json
{
"Status": "Active",
"ProgressStages": 7,
"Task": "803sldjfa-c7e0sd-1ds1e4-a3wf6-421aa90e079f",
"ProgressCurrentStage": 4,
"ProgressStageTimeLeft": -1,
"Added": "2015-03-12 12:15:32",
"TaskType": "VideoToVideo",
"ProgressStagePercentage": 28,
"Cause": "Active",
"Stage": "Converting"
}
Otherwise the response will look similar to this:
HTTP 200 OK
Content-Type: application/json
{
"task_uuid": "803sldjfa-c7e0sd-1ds1e4-a3wf6-421aa90e079f",
"conversion_profile": "VIDEO2MP4",
"start_date": "2015-03-12T12:15:30Z",
"end_date": "2015-03-12T12:17:25Z",
"status": "Completed",
"sources_size": 7266300,
"targets_size": 17820771,
"slide_count": null,
"page_count": null,
"word_count": null,
"video_length": "0",
"charge": 2.5087071,
"dl_url": [
"s3://username:password@my_aws_bucket/my_path/my_file_out.mp4",
"s3://username:password@my_aws_bucket/my_path/my_file_thumb.jpg",
]
}
The task processing has now finished and you should be able to retrieve your data from your Amazon S3 drive.
EncodeMagic supports a number of configuration options:
The following parameters are included in the JSON dictionary as simple key:value
pairs.
Keys are always strings
containing the parameter name.
Please note that parameter names are case sensitive
.
Provides the Conversion Profile of the task as a string. Required. Type: string
.
Conversions details (like formats, bitrates, filters, etc) are determined through a Conversion Profile. There is a very good selection of predefined Conversion Profiles made available by EncodeMagic. In most cases, these predefined Profiles will fill your needs. This parameter provides the selected Conversion Profile for the specific task.
Provides a string ID used by the Application for reporting reasons. Optional. Type: string
.
This ID should be unique for each of the tasks even though EncodeMagic does not perform any cross-checks. This custom ID is used only in logs, reports and billing. It is limited to internal use.
Provides a URL that will be called when the Task has finished processing. Required. Type: string
.
Set by the user, this field is required so that when a task is finished, EncodeMagic performs a GET
request to that URL to notify about the end of the encoding operation. Please note that this does not always imply a successful conversion operation.
Affects Pricing. Provides the Priority that this Task will run under. Optional. Type: string
.
Currently under construction. Different Priorities are priced differently, allowing for Applications to have the optimum balance between cost and performance. By default, all Tasks are run in the default Normal
priority.
Valid string values are:
normal
: The task will run under normal priority, as most of the tasks do, ranging between 25%-100% of CPU encoding time (depending on load)high
: The task will run under high priority, ranging between 75%-100% of CPU encoding time (depending on load)idle
: The task will run under very low priority, ranging between 5%-100% of CPU encoding time (depending on load)Provides the input media for the Task. Required. Type: list
(of dictionaries).
Sources are the input media files which are used for the Task. Each Source usually represents a single file but you may choose to include more than one if for instance you need to include a watermark along with your video. Sources are collected before initiating encoding.
The Sources
element is a JSON List
, containing JSON mappings/dictionaries each representing a single Source. They can take the following options:
Provides the identification for this Source, as defined in the selected Encoding Profile. Required. Type: string
.
All Encoding Profiles identify input media using the SourceID. For example, a SourceID of "MainVideo" may indicate a Source that will provide the video for the final video, while a SourceID of "AudioInput" may indicate a Source that will provide the audio for the final video.
Provides the URL or service that will be used to retrieve the Source. Required. Type: string
.
HTTP GET
is the currently supported method with nore protocols to follow soon: FTP, SCP, S3
.
Specifies the target media for the Task. Required. Type: list
(of dictionaries).
Targets are the resulting media files that are produced by EncodeMagic. Each Target represents a single file.
Targets are stored after the encoding process has completed.
The Targets
element is a JSON List, containing JSON mappings/dictionaries each representing a Target. Documentation for each of the parameneters follows:
Provides the identification for this Target, as defined in the selected Encoding Profile. Required. Type: string
.
All Encoding Profiles identify resulting media using the TargetID
attribute. For instance, a TargetID
of OutputSD
may indicate a Target that will be of Standard Definition quality, while a TargetID
of OutputHD
may indicate a Target that will be of High Definition quality. TargetID
should be defined for each and every of the targets
Provides the filename for this Target. Required. Type: string
.
Targets can be stored using a selection of protocols/services. This parameter specifies the URL where the file will be stored. The URL contains location and access credentials, or may indicate special handling. Amazon S3
is the currently supported protocol with more to follow soon: FTP, SCP, HTTP PUT
.
Provides the identification for this Target, as defined in the selected Encoding Profile. Required. Type: string
.
The Target will be saved under this filename and then stored to the TargetURL
specified. Please note that Encodemagic may change the extension, according to the Encoding Profile you selected, to match the output format.
Allows the user to set the maximum resolution for a video. Can take one of the following values: '360p', '720p', '1080p'
. Optional. Type: string
.
The attribute Resolution
can be set for those cases that we need to downscale the original video. If the attribute is set, the resolution of the processed file will be the smaller setting between the specified resolution and the original video dimensions.
Allows a user to specify a new custom resolution for the processed video. Optional. Type: string
.
EncodeMagic allows the resizing of videos in which case the following attributes must also be set:
Type: string
Type: string
Allows a user to tweak the bitrate attribute of the processed video. Can take one of the following values: 'Low', 'Medium', 'High'
. Optional. Type: string
.
The Bitrate
attribute can be set to control the amount of available bitrate in the produced video. As a rule of thumb, whenever a video contains quick movement and scene transitions a higher bitrate is usually prefered.
Requests use the HTTP GET
method at:
http://api.rs.encodemagic.com:80/v1/tasks/TaskID
where TaskID
is the ID of the task returned after the task submission earlier.
While a task is in Active
state, (which means it is currently being processed by the system and has't yet completed nor failed either) EncodeMagic can provide some useful information about its state:
{
'Task': '5227291e-d89a-11e1-8b1c-3202dddf66e1',
'Added': '2012-06-25T13:45:01',
'Status': 'Active',
'Cause': 'Active',
'Stage': 'WaitingSource',
'ProgressStages': 6,
'ProgressCurrentStage': 1,
'ProgressStagePercentage': 12,
'ProgressStageTimeLeft': 26524,
'ProgressPercentage': 0.056,
'ProgressTimeLeft': 77543,
}
Type: string
This Task identification string is used in all subsequent requests, in order to identify the Task in question. This string is unique.
Type: string
The date/time (based on UTC) is provided as a string in the ISO 8601
format, e.g. 2012-07-31T15:09:10.
Type: string
.Possible values are:
Active
:Completed
:Failed
:Type: string
.The Cause can be used to display a proper message to the end user, or to notify the system administrator.
Type: string
.The Task goes through a series of Stages. This element provides the current Stage of the Task. Note that the Stage is not linked to the Status of the Task, for instance in a Task with Failed
Status, the Stage attribute will indicate at which point the failure occured. Possible values are:
Preparing Task
- (Stage number: 0).Waiting Sources
- (Stage number: 1).Receiving Sources
- (Stage number: 2).Waiting Conversion
- (Stage number: 3).Converting
- (Stage number: 4).Waiting Storage
- (Stage number: 5).Storing
- (Stage number: 6).Completed
- (Stage number: 7).Type: integer
.This is provided for easily creating progress indicators for end-users. For now, this is always equal to 7. Please note that this is a JSON integer value.
Type: float
.This is provided for easily creating progress indicators for end-users. See "Stage" element above.
Under all Stages, if the progress can't be retrieved for any reason, the value is set to -1.
ProgressStageTimeLeft
, ProgressPercentage
and ProgressTimeLeft
have not yet been implemented and you can safely ignore them for now.
After a task has finished processing, which means that is no longer in Active
state, the HTTP RESPONSE
upon a task STATUS REQUEST
at:
http://api.rs.encodemagic.com:80/v1/tasks/TaskID
slightly changes to this:
{
"task_uuid": "de0192c2-cd5d-11e4-bd47-421aa90e079f",
"conversion_profile": "VIDEO2MP4",
"start_date": "2015-03-20T10:59:36Z",
"end_date": "2015-03-20T11:02:54Z",
"status": "Completed",
"sources_size": 31230560,
"targets_size": 12992503,
"slide_count": null,
"page_count": null,
"word_count": null,
"video_length": "0",
"charge": 4.4223063,
"dl_url": [
"http://mybucket.s3.amazonaws.com/file_out.mp4"
]
}
Let's break down what all those new attributes are:
Type: string
The same identification string
as Task. It's only been renamed as task_uuid.
ConversionProfile
. See the configuration section.Type: string
Refers to the conversion profile used.
Type: string
The date/time (based on UTC) is provided as a string in the ISO 8601
format, e.g. 2012-07-31T15:09:10.
Type: string
The date/time (based on UTC) is provided as a string in the ISO 8601
format, e.g. 2012-07-31T15:09:10.
Type: string
This is the exact same Status attribute like before when the task was in progress. However at this time it can only take values the Completed
or Failed
. If this is not the case with a particular task, then you should contact support.
Type: integer
This is the total amount of size of all the sources of specific task in bytes.
Type: integer
After all processing is done, the new media, whether it is just one or multiple targets, will be added up and displayed in bytes here.
Type: integer
Once a presentation file is submitted in a source, regardless of the desired output format, its slides will be counted and showed here after the task finishes processing. Whenever this value is null
then the source wasn't a presentation file.
Type: integer
Once a document file is submitted in a source, regardless of the desired output format, its pages will be counted and showed here after the task finishes processing. Whenever this value is null
then the source wasn't a document file.
Type: integer
The attribute represents the length of the video in seconds. If its value is null
then the given file wasn't video file.
Type: float
This is the total charge for a specific task once it has finished processing. Charging takes into account a number of parameters such as the original file size, the quality and the type of the given media. Please refer to our pricing policy for further details.
Type: list
These are the final download links once a task is complete. If the list contains an empty string then something must have gone wrong and the task has probably failed.
Unfortunately new registrations are now closed.