media

media / VideoTransform / 0.6.3

README.md

Video Transform

This algorithm uses an image processing algorithm to alter each frame of a video, then recombines it back into a freshly transformed video file.

note: This algorithm takes longer than most other algorithms as it recursively calls an image algorithm over each frame of a video file, make sure to add a custom timeout to your algorithm call.

note: This algorithm is royalty free, but the image processing algorithms it can call might not be, check your account's credit balance before running this algorithm on a custom video.

Changelog

0.6.3 - August 1st, 2018:

  • Added a early termination watchdog thread that detects processing jobs that are forecasted to take longer than the maximum timeout of 50 minutes.
  • various bug fixes that should improve stability and early termination in the event of a detected failure.

0.5.0 - May 23, 2017:

  • Added Smart Video Downloader support to resolve a compressed gzip request problem
  • with Smart Video Downloader added, input_file may now point to any web hosted URL, including youtube, vimeo, etc.

Input

input_file: String,
output_file: String,
algorithm: String,
advanced_input: Json,
fps: Double,
image_compression: Int,
video_compression: Int
  • input_file - (required) - The input url of the video file, can be any standard video container format (mp4, mkv, avi, etc), can be an http/https url or a data connector uri(data://, s3://, dropbox://, etc).
  • output_file - (required) - The output url of the altered video file, must be a data connector uri (data://, s3://, dropbox://, etc).
  • algorithm - (required) - The image processing algorithmia algorithm uri, if no default mode is found for that algorithm, advanced_input must be defined.
  • advanced_input - (optional) - if you have advanced requirements or want to use an algorithm with no default parameters, See Advanced Input.
  • fps - (optional) - If you have a desired fps sampling rate, input it here. defaults to the input video's fps.
  • image_compression - (optional) - if you want to improve performance of processing, it's possible to compress each frame using the jpeg compression algorithm, the value provided is the associated compression ratio - from 0 (uncompressed) to 100 (most compressed). If undefined, we use the PNG algorithm and image format instead, beware as some algorithms don't support jpg, or vice versa.
  • video_compression - (optional) - by default, the output video file is raw and uncompressed, if you desire to compress your output video using the libx264 codec, provide a compression ratio value for this element, from 0 (uncompressed) to `100 (most compressed)

Advanced Input

If advanced_input is found, this algorithm will parse it as a json object; finding and replacing keywords relating to uploading and downloading files in both batch and single form with paths that the Video Transform algorithm uses.

The keywords are:

$SINGLE_INPUT - whenever you see a single image input path for an algorithm, this keyword will work

$SINGLE_OUTPUT whenever you see a single image output path for an algorithm, this keyword will work

$BATCH_INPUT - similar to single input keyword, but works for arrays of input files (DeepFilter for example)

$BATCH_OUTPUT - similar to single input keyword, but works for arrays of input files (DeepFilter for example)

Example:

SalNet algorithm default input

{
  "image": "data://deeplearning/example_data/mona_lisa.jpg",
  "location": "data://.algo/temp/test42.png"
}

Video Transform with advanced salnet input


{  
   "input_file": "data://path/to/file.mp4",
   "output_file": "data://save/file.mp4,
   "algorithm": "algo://deeplearning/SalNet/0.1.6",
   "advanced_input": {
  "image": "$SINGLE_INPUT",
  "location": "$SINGLE_OUTPUT"
},
   "fps": Double
}

Output

{  
    "output_file": String
}

  • output_file - the complete algorithmia URI for where the output video file has been uploaded to.

Default Options

This algorithm has default parameters set up for a number of algorithms, this list will grow as new image altering algorithms are released:

  • DeepFilter - uses version 0.6.0, filterName is gan_vogh - (deeplearning/DeepFilter)
  • SalNet - uses version 0.2.0 - (deeplearning/SalNet)
  • Colorful Image Colorization - uses version 1.1.6 - (deeplearning/ColorfulImageColorization)

Examples

DeepFilter default input

{  
   "input_file":"data://media/videos/lounge_demo.mp4",
   "output_file":"data://.algo/temp/altered_lounge_demo.mp4",
   "algorithm":"algo://deeplearning/DeepFilter"
}

DeepFilter advanced input

{  
   "input_file":"data://media/videos/lounge_demo.mp4",
   "output_file":"data://.algo/temp/altered_lounge_demo.mp4",
   "algorithm":"algo://deeplearning/DeepFilter/0.3.2",
   "advanced_input":{  
      "images":"$BATCH_INPUT",
      "savePaths":"$BATCH_OUTPUT",
      "filterName":"neo_instinct"
   }
}

SalNet default input with fps

{  
   "input_file":"data://media/videos/lounge_demo.mp4",
   "output_file":"data://.algo/temp/altered_lounge_demo.mp4",
   "algorithm":"algo://deeplearning/SalNet",
   "fps": 14.24
}

Credits

All video processing is handled by FFMpeg, which is a fantastic video/image manipulation tool that can be found here