The /video/encode Robot

Our /video/encode robot

Transloadit offers a variety of features to reduce video size while maintaining quality, as well as add effects like watermarks.

The /video/encode Robot encodes, resizes, applies watermarks to videos and animated GIFs.

The /video/encode Robot's Parameters

Name Type Default Description
preset String "flash" Converts a video according to pre-configured settings. If you specify your own FFmpeg parameters using the Robot's ffmpeg parameter and you have not specified a preset, then the default "flash" preset is not applied. This is to prevent you from having to override each of the flash preset's values manually. For a list of video presets, see video presets.
width Integer(1-1920) Width of the input video Width of the new video, in pixels.
height Integer(1-1080) Height of the input video Height of the new video, in pixels.
resize_strategy String "pad" See the available resize strategies.
background String "00000000" The background color of the resulting video the "rrggbbaa" format (red, green, blue, alpha) when used with the "pad" resize strategy. The default color is black.
rotate Integer Auto Forces the video to be rotated by the specified degree integer. Currently, only multiples of 90 are supported. We automatically correct the orientation of many videos when the orientation is provided by the camera. This option is only useful for videos requiring rotation because it was not detected by the camera. If you set rotate to false no rotation is performed, even if the metadata contains such instructions.
hint Boolean false Enables hinting for mp4 files, for RTP/RTSP streaming.

Example use cases featuring the /video/encode robot

See the robot in action with some live demos and code samples right here on our website:

Export a video to YouTube

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "ipad-high"
    },
    "store": {
      "use": "video",
      "robot": "/youtube/store",
      "username": "YOUR_YOUTUBE_USERNAME",
      "password": "YOUR_YOUTUBE_PASSWORD",
      "title": "Some title",
      "description": "Some description",
      "category": "People",
      "keywords": "testing, example"
    }
  }
}

Encode a video, extract 8 thumbnails and store everything in your S3 bucket

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "flash_encoding": {
      "use": ":original",
      "robot": "/video/encode",
      "preset": "flash",
      "width": 640,
      "height": 480
    },
    "extracted_thumbs": {
      "use": "flash_encoding",
      "robot": "/video/thumbs",
      "result": true
    },
    "store": {
      "robot": "/s3/store",
      "use": [
        "flash_encoding",
        "extracted_thumbs"
      ],
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Automatically extract uploaded archives

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "archives": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.mime}",
          "regex",
          "application/(rar|x-7z-compressed|x-cab|x-cpio|x-debian-package|x-gtar-compressed|x-gzip|x-lzh|x-redhat-package-manager|x-tar|zip)"
        ]
      ],
      "error_on_decline": false
    },
    "non-archives": {
      "use": ":original",
      "robot": "/file/filter",
      "declines": [
        [
          "${file.mime}",
          "regex",
          "application/(rar|x-7z-compressed|x-cab|x-cpio|x-debian-package|x-gtar-compressed|x-gzip|x-lzh|x-redhat-package-manager|x-tar|zip)"
        ]
      ],
      "error_on_decline": false
    },
    "extracted": {
      "use": "archives",
      "robot": "/file/decompress"
    },
    "encoded-ipad": {
      "use": [
        "non-archives",
        "extracted"
      ],
      "robot": "/video/encode",
      "preset": "ipad-high",
      "result": true
    },
    "encoded-webm": {
      "use": [
        "non-archives",
        "extracted"
      ],
      "robot": "/video/encode",
      "preset": "webm",
      "result": true
    },
    "exported": {
      "use": [
        ":original",
        "encoded-ipad",
        "encoded-webm"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Reject videos that do not have an audio track

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "files": {
      "use": ":original",
      "robot": "/file/filter",
      "declines": [
        [
          "${file.meta.audio_bitrate}",
          "=",
          ""
        ]
      ],
      "error_on_decline": true
    },
    "iphone_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "iphone"
    }
  }
}

Specify multiple encoding Steps for a single file

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "flash_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "flash",
      "width": 854,
      "height": 480
    },
    "iphone_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "iphone"
    },
    "thumbnails": {
      "use": ":original",
      "robot": "/video/thumbs"
    },
    "resized_thumbs": {
      "robot": "/image/resize",
      "use": "thumbnails",
      "result": true,
      "width": 130,
      "height": 130
    },
    "export": {
      "robot": "/s3/store",
      "use": [
        ":original",
        "flash_video",
        "iphone_video",
        "resized_thumbs"
      ],
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Automatically process multiple file types

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "image_thumbs": {
      "use": ":original",
      "robot": "/image/resize",
      "result": true,
      "format": "png",
      "width": 320,
      "height": 240
    },
    "video_thumbs": {
      "use": ":original",
      "robot": "/video/thumbs",
      "result": true,
      "width": 320,
      "height": 240,
      "resize_strategy": "pad",
      "background": "#000000",
      "count": 4
    },
    "encode_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "flash",
      "width": 640,
      "height": 480
    },
    "store": {
      "use": [
        "image_thumbs",
        "video_thumbs",
        "encode_video",
        ":original"
      ],
      "robot": "/s3/store",
      "bucket": "YOUR_S3_BUCKET",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET"
    }
  }
}

Encode video for Android, preserving the original quality

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "android-preserve-quality": {
      "use": ":original",
      "robot": "/video/encode",
      "preset": "android",
      "result": "true",
      "ffmpeg_stack": "v2.2.3",
      "width": "${file.meta.width}",
      "height": "${file.meta.height}",
      "ffmpeg": {
        "b:v": "${file.meta.video_bitrate}",
        "maxrate": "${file.meta.video_bitrate}",
        "bufsize": "${file.meta.video_bitrate}",
        "r": "${file.meta.framerate}",
        "ar": "${file.meta.audio_samplerate}",
        "b:a": "${file.meta.audio_bitrate}"
      }
    },
    "exported": {
      "use": [
        ":original",
        "android-preserve-quality"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Encode video for Android

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "android_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "android"
    }
  }
}

Encode video for iPhone and strip the sound

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "iphone_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "iphone",
      "ffmpeg": {
        "an": true
      }
    }
  }
}

Encode a video into WebM

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "webm_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "webm",
      "width": 320,
      "height": 240
    }
  }
}

Extract 10 thumbnails and modify their size

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "flash_encoding": {
      "use": ":original",
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "preset": "flash",
      "width": 640,
      "height": 480
    },
    "extracted_thumbs": {
      "use": "flash_encoding",
      "robot": "/video/thumbs",
      "count": 10
    },
    "small": {
      "use": "extracted_thumbs",
      "robot": "/image/resize",
      "result": true,
      "width": "30",
      "height": "30"
    },
    "thumb": {
      "use": "extracted_thumbs",
      "robot": "/image/resize",
      "result": true,
      "width": "75",
      "height": "75"
    },
    "big": {
      "use": "extracted_thumbs",
      "robot": "/image/resize",
      "result": true,
      "width": "120",
      "height": "120"
    }
  }
}

Implement HTTP Live Streaming (HLS)

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "low": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_270p"
    },
    "mid": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_360p"
    },
    "high": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_540p"
    },
    "adaptive": {
      "robot": "/video/adaptive",
      "use": {
        "steps": [
          "low",
          "mid",
          "high"
        ],
        "bundle_steps": true
      },
      "technique": "hls",
      "playlist_name": "my_playlist.m3u8"
    },
    "store": {
      "robot": "/s3/store",
      "use": "adaptive",
      "path": "hlstest/${file.meta.relative_path}/${file.name}",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Implement MPEG-Dash using Transloadit

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "270p_video": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_270p_video"
    },
    "360p_video": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_360p_video"
    },
    "32k_audio": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_32k_audio"
    },
    "64k_audio": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_64k_audio"
    },
    "adaptive": {
      "robot": "/video/adaptive",
      "use": {
        "steps": [
          "270p_video",
          "360p_video",
          "32k_audio",
          "64k_audio"
        ],
        "bundle_steps": true
      },
      "technique": "dash",
      "playlist_name": "my_playlist.mpd"
    },
    "store": {
      "robot": "/s3/store",
      "use": "adaptive",
      "path": "dashtest/${file.meta.relative_path}/${file.name}",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Surround a video with a frame using a watermark

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "vid_frame_watermark": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "webm",
      "width": 640,
      "height": 480,
      "watermark_url": "https://transloadit.com/assets/images/waterframe.png",
      "watermark_size": "100%",
      "watermark_position": "top-left"
    }
  }
}

Apply a watermark to your videos

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "vid_logo_watermark": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "flash",
      "width": 854,
      "height": 480,
      "watermark_url": "https://transloadit.com/assets/images/robots/170x170/video-encode.jpg",
      "watermark_size": "25%",
      "watermark_position": "bottom-right"
    }
  }
}


Did you know?

You can easily combine Robots to create powerful workflows, unique to your business.

This is the power of Transloadit.