
/video/encode robot
Takes a single video file and converts it to a given format.
Optional parameters
| Name | Type | Default | Description |
|---|---|---|---|
| realtime | boolean | false |
Allows to encode a video while it is still uploading! If the uploaded video is not streamable, the robot automatically falls back to normal encoding after the upload. |
| preset | string | "" |
Converts a video using pre-configured settings. Click here for a list of presets. |
| width | 1 - 1920 |
Width of the input video | Size for the new video in px.. |
| height | 1 - 1080 |
Height of the input video | Height for the new video in px. |
| resize_strategy | string | "pad" |
Click here for a list of available resize strategies. |
| rotate | integer | (auto) |
Force the video to be rotated by the given integer of degrees. Currently only multiples of 90 are supported. Note: We automatically correct the orientation for many videos if the camera provides that information. This option is only useful for videos you need to rotate because the camera did not record the rotation. |
| ffmpeg | object | {} |
An object with parameters to pass to FFmpeg. Check the
FFmpeg documentation for
available options. If you are using a preset, the options given here
will be merged on top. The ffmpeg r parameter (framerate) has a default value of 25 and a maximum value of 60.
|
| hint | boolean | false |
Enables hinting for mp4 files for RTP/RTSP streaming. |
Watermark parameters
| Name | Type | Default | Description |
|---|---|---|---|
| watermark_url | string | "" |
Url to a png image to overlay over this image. |
| watermark_position | string/array | "center" |
The position you'd like the watermark to have. Available options
are: "center", "top", "bottom", "left", "right". You can also
combine options, for example "bottom-right".
You can also specify an array of possible values out of which one value will be picked randomly.
E.g. ["center","left","bottom-left","bottom-right"]Note that this will push the watermark into the respective corner. If you want a specific pixel-offset on the watermark you need to include this in the form of padding into the image itself. |
| watermark_size | string | "" |
The size in percent for this watermark. E.g. "50%".
|
| watermark_resize_strategy | string | "fit" |
Supports "fit" and "stretch".
|
Presets
Getting encoding options right can be very difficult. To make your life easier, Transloadit offers presets that are optimized for various devices & platforms.
We'll expose some main characteristics like codecs & bitrates used. More specific encoding options we use, are available at request.
| Preset | Video codec | Video format | Video res | Video bitrate | Audio codec | Audio bitrate | Audio sampling frequency |
|---|---|---|---|---|---|---|---|
android-high | libx264 | mp4 | 480x320 | 700k | libfaac | 128k | 48k |
android-low | libx264 | mp4 | 480x320 | 96k | libfaac | 64k | 48k |
android | libx264 | mp4 | 480x320 | 512k | libfaac | 128k | 48k |
flash | flv | flv | 320x240 | 512k | libmp3lame | 64k | 44100 |
ipad-high | libx264 | mp4 | 1024x768 | 1200k | libfaac | 128k | 48k |
ipad-low | libx264 | mp4 | 1024x768 | 512k | libfaac | 128k | 48k |
ipad | libx264 | mp4 | 1024x768 | 700k | libfaac | 128k | 48k |
iphone-high | libx264 | mp4 | 480x320 | 700k | libfaac | 128k | 48k |
iphone-low | libx264 | mp4 | 480x320 | 96k | libfaac | 64k | 48k |
iphone | libx264 | mp4 | 480x320 | 512k | libfaac | 128k | 48k |
mp3 | mp3 | libmp3lame | 128000 | 44100 | |||
webm | libvpx | webm | 700k | libvorbis | 128k | 48k | |
wmv | wmv2 | asf | wmav2 |
You can use our presets as templates, and override specific options if needed.
In this example we adjust the iPhone preset for iPhone4 usage, which has a
bigger screen (width, height), and we'll also set a higher video bitrate
because of that (b).
{
"steps": {
"iphone4": {
"robot": "/video/encode",
"preset": "iphone",
"width": 960,
"height": 640,
"ffmpeg": {
"b": "1200K"
}
}
}
}
Demos
- Encode a video for the iphone
- Encode a video for android
- Encode a video into flash
- Encode a video into webm
- Encode a video into flash and mov
- Encode a video into 640x480 pixels using the pad strategy
- Apply a watermark onto a video
- Encode a video changing its bitrate to 2000k
- Encode a video in realtime
- Surround a video with a frame