output_asset
Here we describe the type of output you can generate with CT. We describe the JSON data you must send to the stack in the output_asset
section of the JSON payload you send to the TranscodeActivity
.
Navigation Menu
-
All transcoding requires common attributes regardless of their types.
-
Use this syntax to transcode a video to another video. We use
ffmpeg
command for this. -
Presets allow you to easily describe transcoding prameters in a file and ask the Transcoding Activity to read it and pass it to FFMpeg.
-
If you want to overlay a watermark image on top of your video. Use those options
-
Use these options to output thumbnails from a video. We use
ffmpeg
command for this. -
Use these options to output an image from another image. image to image transcoding. We use
convert
command for this.
Common attributes
Those options are common to all output types.
{
...
"output_asset": {
"type": "VIDEO",
"bucket": "ClientA-bucket-out",
"file": "/output1/test1_sd.mp4",
"s3_rrs": true,
"s3_encrypt": true,
...
These are the common JSON fields describing any output files of any types.
The output_type field is dependent on the input_type field. You cannot convert a VIDEO into a DOC for example.
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
type | string | none | yes | Type of the file to ouput | VIDEO, THUMB, IMAGE |
bucket | string | none | yes | S3 bucket where the ouput file will be uploaded | any |
file | string | none | yes | Path and filename of the file to generate and upload | any |
s3_rrs | string | false | no | Activate Reduced redundancy or not in S3 storage | true, false |
s3_encrypt | string | false | no | Activate backend storage encryption | true,false |
Video Output
You can use presets:
{
...
"output_asset": {
"type": "VIDEO",
"bucket": "ClientA-bucket-out",
"file": "/output1/test1_sd.mp4",
"s3_rrs": true,
"s3_encrypt": true,
"preset": "720p-generic.json",
"watermark": {
"bucket": "ClientA-bucket-in",
"file": "/watermark/logo.png",
"size": "75.2:28.4",
"opacity": 0.2,
"x": -20,
"y": -20
}
}
}
Or you can execute arbitrary FFMpeg commands:
{
...
"output_asset": {
"type": "VIDEO",
"bucket": "ClientA-bucket-out",
"file": "/output1/video1.mp4",
"s3_rrs": true,
"s3_encrypt": true,
"custom_cmd": "ffmpeg -i ${input_file} -c:v libx264 -preset slow -crf 22 -c:a copy ${watermark_options} ${output_file}",
"watermark": {
"bucket": "ClientA-bucket-in",
"file": "/no-text-96px.png",
"size": "96:96",
"opacity": 0.2,
"x": -20,
"y": -20
}
}
}
There are the JSON fields describing VIDEO output files when using Presets. You can override presets values within the JSON.
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
preset | object | none | yes | Preset to use to transcode the file | Find presets |
size | string | original size | no | Define output size. Valid for videos and images only | |
video_codec | string | from preset | no | Override the video codec used by preset | ffmpeg codec |
audio_codec | string | from preset | no | Override the audio codec used by preset | ffmpeg codec |
video_bitrate | string | from preset | no | Override video bitrate used by preset | valid bitrate |
audio_bitrate | string | from preset | no | Override audio bitrate used by preset | valid bitrate |
frame_rate | string | from preset | no | Override framerate used by preset | valid framerate |
watermark | object | none | no | Describe watermark for the video | see Watermark section |
keep_ratio | boolean | true | no | Keep the ratio of the original video. 4:3 or 16:9 | true,false |
no_enlarge | boolean | true | no | Prevent enlarging the video size from original, even if bigger size is provided. | true,false |
Presets
{
"name": "System preset: Generic Apple TV 3G",
"description": "Generic transcoding preset for: Apple TV 3G, Roku HD/2 XD",
"size": "1920x1080",
"frame_rate": 30,
"video_bitrate": "5000k",
"audio_bitrate": "160k",
"video_codec": "libx264",
"audio_codec": "libfdk_aac",
"video_codec_options": "MaxReferenceFrames:3,Profile:high,Level:4"
}
The presets can contain the following entries but can be overriden by providing the same entry in your JSON payload:
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
name | string | no | yes | Name of the preset | n/a |
description | string | no | yes | Description of the preset | n/a |
size | string | original size | yes | Define output size. Valid for videos and images only | |
video_codec | string | no | yes | Override the video codec used by preset | ffmpeg codec |
audio_codec | string | no | yes | Override the audio codec used by preset | ffmpeg codec |
video_bitrate | string | no | yes | Override video bitrate used by preset | valid bitrate |
audio_bitrate | string | no | yes | Override audio bitrate used by preset | valid bitrate |
frame_rate | string | no | yes | Override framerate used by preset | valid framerate |
video_codec_options | string | no | no | Codec options such as: “MaxReferenceFrames:3,Profile:high,Level:4” |
A list of pre-made presets can be found in the CT project and here: https://github.com/sportarchive/CloudTranscode-FFMpeg-presets
Watermark
...
"watermark": {
"bucket": "ClientA-bucket-in",
"file": "/watermark/logo.png",
"size": "75.2:28.4",
"opacity": 0.2,
"x": -20,
"y": -20
}
...
Use this object within a VIDEO output description to overlay an image on top of the video.
You can control many aspects of that image using the options below.
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
butcket | string | none | yes | Bucket name where the watermark is located | any |
file | string | none | yes | Filename and path of the file containing the watermark | any |
size | string | none | yes | Size of the watermark in the video result | x:y. Use -1 on x OR y, to provide no value and keep ratio |
opacity | string | 0.7 | no | Change the default watermark opacity | 0.1 to 1.0 |
x | string | -10 | no | Change the watermark position. In pixels. | -0 to -n, 0 to n |
y | string | -10 | no | Change the watermark position. In pixels. | -0 to -n, 0 to n |
Thumbnail Output
Generates a thumbnail from a precise location in the video (in seconds)
{
...
"output": {
"type": "THUMB",
"mode": "snapshot",
"bucket": "ClientA-bucket-out",
"file": "/output1/thumbs/test1_thumb.jpg",
"s3_rrs": true,
"s3_encrypt": true,
"size": "160:120",
"snapshot_sec": 5
}
}
Generates N thumbnails at each intervals (in seconds)
{
...
"output": {
"type": "THUMB",
"mode": "intervals",
"bucket": "ClientA-bucket-out",
"file": "/output1/thumbs_interval/test2_thumb.jpg",
"s3_rrs": true,
"s3_encrypt": true,
"size": "-1:159",
"intervals": 5
}
}
These are the output attributes you must provide to generate thumbnails from a video. Thumbnails are an output_type on its own.
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
mode | string | snapshot | no | Type of thumbnails generation needed | snapshot, intervals |
bucket | string | none | yes | S3 bucket and path where the ouput thumbnails will be uploaded | any |
file | string | none | yes | filename for your thumbnails.We will append sequence number | any |
intervals | integer | 10 | no | Override default interval in seconds. | any |
snapshot_sec | interger | 0 | no | Second in the video when to take the snapshot | any |
size | string | none | yes | Size of the thumbnails | x:y. Use -1 on x OR y, to provide no value and keep ratio |
Image Output
Generates an image from another image.
{
...
"output": {
"type": "IMAGE",
"bucket": "ClientA-bucket-out",
"file": "/output1/images/image.*",
"s3_rrs": true,
"s3_encrypt": true,
"resize": "180x180",
"quality": 70,
"crop": "600x600+0+0"
}
}
These are the output attributes you must provide to generate a new image from another image.
key | type | default | mandatory | description | values |
---|---|---|---|---|---|
bucket | string | none | yes | S3 bucket and path where the ouput image will be uploaded | any |
file | string | none | yes | filename for your new image. The extension can be .* to retain the source file extention. Or you can specify anothe extension to transform the file. JPEG to PNG for example |
any |
resize | string | none | no | Resize the output image to the desired size | /\d+x\d+/ |
crop | string | none | no | Crop the source image to the desired size and coordinate. | Follow convert option specs: http://www.imagemagick.org/Usage/crop/ |
quality | integer | none | no | Set the quality of the output image. | 0-100. 100 being the best quality. Refer to: http://www.imagemagick.org/script/command-line-options.php#quality |
Custom command
Both VIDEO and IMAGE transcoding can accept a custom command so you can run the command you want even if it’s not support by the default JSON format.
You can craft your own custom command and CT will execute it for you. In order to reference the input file, watermark options and the wanted output file, three keywords are available to use in your command line. Those keywords will be automatically replaced by CT at runtime by the proper value.
${input_file}
: Will be replaced by the location on the local filesystem of your input file specified in theinput_asset
section. The file referenced in theinput_asset
section is downloaded on the local disk in /tmp.${watermark_options}
: Only usable for VIDEO output. This will be replaced by the proper options to overlay a watermark on your video. Just specify awatermark
section in theoutput_asset
section (see below for details) and CT will add the proper options and will download the image for you.${output_file}
: This will be replaced by the location and name of the wanted file. It will be located in /tmp. The resulting file will be uploaded for you to the desired S3 location.
For examples, see the client_example/input_samples
folder in the CPE project. There are example JSON files there that illustrate the different options you have.