Display and delivery copies
Make a smaller copy of a picture or a video for a page, a list or a messaging app: fitted inside a box by its longest side, never enlarged, with no metadata, and no larger than you allow.
Pictures
Send ffmpeg.frames.v1 one image cell and no cell size. max_edge fits the picture inside a square of that many pixels by its longer side, keeping its shape; it is never enlarged and never padded. The picture is first turned upright by its EXIF orientation, so a rotated phone photo comes out upright, and width and height in the result are the upright size. png and webp keep its transparency; jpg lays transparent pixels on black. The finished image carries no metadata: no EXIF, XMP, ICC profile, text or time. if_animated: refuse fails the job with invalid_input for an animated GIF, APNG or WebP; left out, the first frame is used. quality sets WebP and JPEG quality from 1 to 100, and jpeg_qscale gives FFmpeg’s own JPEG scale, 1 to 31, in its place. The other side of a picture fit by max_edge is rounded to the nearest whole pixel, with no step to even, and scaler picks Lanczos, the default, or FFmpeg’s plain bicubic.
{
"service_id": "ffmpeg.frames.v1",
"max_output_bytes": 4194304,
"input": {
"cells": [
{
"kind": "image",
"url": "https://example.com/photo.png",
"if_animated": "refuse"
}
],
"format": "webp",
"quality": 78,
"max_edge": 480
}
}A JPEG for a messaging app
format: jpg writes a baseline JPEG in full-range 4:2:0. jpeg_qscale: 3 is FFmpeg’s -q:v 3.
{
"service_id": "ffmpeg.frames.v1",
"max_output_bytes": 5242880,
"input": {
"cells": [
{
"kind": "image",
"url": "https://example.com/photo.png",
"if_animated": "refuse"
}
],
"format": "jpg",
"jpeg_qscale": 3,
"max_edge": 2048
}
}Videos
Send ffmpeg.transcode.v1 with max_edge: the picture fits inside that square by its longer side, as displayed, never enlarged and with no padding. The other side is worked out to the nearest whole pixel, a half up, and then each side is rounded down to an even number: 864×496 at 640 is 640×366. The scaler is bicubic. crf, x264_preset, gop, max_bitrate_kbps and buffer_kbps set the libx264 encode, and pixel_format: yuv420p makes the picture 8-bit 4:2:0. With max_edge, or any field later than height, and no fps, every output frame carries its own source frame’s time, with no frame added or dropped and no time repeated or reordered, including in a variable-frame-rate recording from a phone or a browser, so the picture is as long as the source’s; the result reports picture_seconds and source_picture_seconds to compare. audio_streams: all keeps every sound stream of the source, each as AAC at audio_bitrate_kbps, or 128 kbps for stereo and 69 for mono when it is left out, with its own rate and channels, and the result reports how many were written. Every output has its index at the front of the file, so it starts playing before it has all arrived. strip_metadata removes the source’s tags and chapters. max_source_seconds refuses a source whose picture is longer.
{
"service_id": "ffmpeg.transcode.v1",
"max_output_bytes": 25165824,
"input": {
"input_url": "https://example.com/take.mov",
"video_codec": "libx264",
"max_edge": 640,
"crf": 29,
"x264_preset": "veryfast",
"max_bitrate_kbps": 900,
"buffer_kbps": 1800,
"gop": 48,
"pixel_format": "yuv420p",
"audio_streams": "all",
"audio_bitrate_kbps": 96,
"strip_metadata": true,
"max_source_seconds": 90
}
}A video under a size
size_budget works the video bitrate cap out from the picture’s length: the smaller of max_kbps and floor(bytes × 8 ÷ seconds ÷ 1000) − reserve_kbps, used as the encoder’s maximum rate with a buffer twice it. When the cap is below low_rate.below_kbps the picture fits low_rate.max_edge instead of max_edge. The example caps a 60-second picture at 1985 kbps and a 300-second one at 307 kbps, and fits the second inside 640. The result carries video_bitrate_cap_kbps.
{
"service_id": "ffmpeg.transcode.v1",
"max_output_bytes": 16777216,
"input": {
"input_url": "https://example.com/take.mov",
"video_codec": "libx264",
"max_edge": 1280,
"crf": 24,
"x264_preset": "veryfast",
"gop": 48,
"pixel_format": "yuv420p",
"size_budget": {
"bytes": 15728640,
"reserve_kbps": 112,
"max_kbps": 2800,
"low_rate": {
"below_kbps": 600,
"max_edge": 640
}
},
"audio_streams": "all",
"audio_bitrate_kbps": 96,
"strip_metadata": true,
"max_source_seconds": 600
}
}A size limit for any job
max_output_bytes, beside service_id, is the largest file you accept. A larger one is not kept: the job fails with output_too_large, is not tried again and is not charged.
Write the copy to your own storage
output_upload, beside service_id, takes a url that accepts a PUT, such as a presigned PUT URL from S3, R2 or Google Cloud Storage, and up to 16 headers sent with it. The renderer puts the finished file there in one PUT, with Content-Type your own header or else the output’s own type, and keeps no copy. A 4xx answer fails the job at once with upload_failed, and a network error or a 5xx is tried twice more. On success the job reads output_delivery buyer_storage, result.output_upload carries the storage’s status and ETag, and GET /v1/jobs/{id}/output answers 409 output_sent_to_buyer_storage. Give the link long enough to cover the queue wait and the render.
{
"service_id": "ffmpeg.frames.v1",
"max_output_bytes": 4194304,
"output_upload": {
"url": "https://bucket.s3.amazonaws.com/previews/photo-480.webp?X-Amz-Signature=…",
"headers": {
"Content-Type": "image/webp"
}
},
"input": {
"cells": [
{
"kind": "image",
"url": "https://example.com/photo.png",
"if_animated": "refuse"
}
],
"format": "webp",
"quality": 78,
"max_edge": 480
}
}Price
A picture costs one image, $0.000063. A video is billed like other FFmpeg work, for the length of its output by size, at $0.00375 per minute for SD.