Create video processing task

ID: video_processing_tasks/create
Upload video with time trimming parameters. User can use the mobile app to upload video and define timing parameters. After that, the request must be processed in the background.

Request

URL
/api/v1/video_processing_tasks.json
Method
POST
Format
json
Headers
Name Value Description Required
Authorization: Token token=:token_value :token_value - is an authorization token value (api_token) Yes
Url params
Data params
{
video_processing_task // document, Video processing task params
{
trim_startinteger, // Video start trimming parameter in seconds; required; example value: 3
trim_endinteger, // Video end trimming parameter in seconds; required; example value: 23
source_videofile // Video multipart data file; required
}
}

Responses

Success
HTTP Status
201 CREATED
Format
json
Data params
{
idstring, // Video processing task database ID; example value: 31946946eb248e6227496fa1
trim_startinteger, // Video start trimming parameter in seconds; example value: 1
trim_endinteger, // Video end trimming parameter in seconds; example value: 21
source_video // document, Source video file details
{
urlstring, // source file url; example value: http://video_processor.dev/system/video_processing_tasks/source_videos/57d4/6ce8/07ae/1d3b/2b95/ad50/original/test_video.mov?1473539304
durationinteger // source file duration; example value: 90
}
,
result_video // document, Result video file details
{
urlstring, // result file url; example value: http://video_processor.dev/system/video_processing_tasks/result_videos/36d4/6ce8/07ae/1d3b/2b75/ad50/original/test_video.mov?1773499304
durationinteger // result file duration; example value: 4
}
,
started_attimestamp, // Task started at unix timestamp
completed_attimestamp, // Task completed at unix timestamp
failed_attimestamp, // Task failed at unix timestamp
created_attimestamp, // Task created at unix timestamp
updated_attimestamp, // Task updated at unix timestamp
statestring, // Task state. Could be: scheduled, processing, done, failed; example value: scheduled
last_errorstring // Task last error message that happened during video processing; example value: FFMPEG: Failed encoding
}
Invalid parameters
HTTP Status
422 UNPROCESSABLE ENTITY
Format
json
Data params
{
errorstring, // Human readable error message; example value: Trim end can't be blank, Trim end is not a number, Source video can't be blank
details // document, error details, can be used for highlighting invalid fields at native app UI
{
trim_endarray, // errors array on specific field; example value: ["can't be blank", "is not a number"]
source_videoarray // errors array on specific field; example value: ["can't be blank"]
}
}
User is not authorized
HTTP Status
401 UNAUTHORIZED
Format
json
Data params
{
errorstring // Api Token is not valid error message; example value: Bad Credentials
}
Sample Call
curl -v -H "Authorization: Token token=YwXdQ64vI5oam8ukfUx4SAtt" --form video_processing_task[trim_start]=3 --form video_processing_task[trim_end]=12 --form video_processing_task[source_video]=@spec/fixtures/videos/test_video.mov http://video_processor.dev/api/v1/video_processing_tasks.json
Sample Response
{
   "id":"57d52ca107ae1d24852e6afe",
   "trim_start":3,
   "trim_end":12,
   "state":"scheduled",
   "last_error":null,
   "source_video":{
      "url":"http://video_processor.dev/system/video_processing_tasks/source_videos/57d5/2ca1/07ae/1d24/852e/6afe/original/test_video.mov?1473588385",
      "duration":15
   },
   "result_video":{
      "url":null,
      "duration":null
   },
   "started_at":null,
   "completed_at":null,
   "failed_at":null,
   "created_at":1473588385,
   "updated_at":1473588385
}