DocsGuides
Sizes and renditions
Resize a video, or write several sizes in one job with presets, keeping the shape.
Name the sizes you want and get one file per size, each from one read of the input. A preset such as
web-1080p or web-720p sets the size, codec and quality; your own fields change any of them
(Presets). These presets never enlarge: an input smaller than the size keeps its
own.
Several sizes in one job#
curl "$VIDEXO_API_URL/v1/jobs" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"talk": "https://example.com/talk.mp4"
},
"outputs": [
{
"name": "hd",
"preset": "web-1080p",
"filename": "talk-1080p.mp4"
},
{
"name": "sd",
"preset": "web-720p",
"filename": "talk-720p.mp4"
}
]
}'Copy failed. The text is selected; copy it with your keyboard.
const response = await fetch(`${process.env.VIDEXO_API_URL}/v1/jobs`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDEXO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"inputs": {
"talk": "https://example.com/talk.mp4"
},
"outputs": [
{
"name": "hd",
"preset": "web-1080p",
"filename": "talk-1080p.mp4"
},
{
"name": "sd",
"preset": "web-720p",
"filename": "talk-720p.mp4"
}
]
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-map 0:v:0 \
-vf "scale='min(iw,1920)':'min(ih,1080)':force_original_aspect_ratio=decrease:force_divisible_by=2" \
-c:v libx264 -preset veryfast -crf 22 -pix_fmt yuv420p \
-map "0:a:0?" \
-c:a aac -b:a 160k -movflags +faststart \
talk-1080p.mp4 \
-map 0:v:0 \
-vf "scale='min(iw,1280)':'min(ih,720)':force_original_aspect_ratio=decrease:force_divisible_by=2" \
-c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
-map "0:a:0?" \
-c:a aac -b:a 128k -movflags +faststart \
talk-720p.mp4Copy failed. The text is selected; copy it with your keyboard.
talk-1080p.mp4 and talk-720p.mp4: H.264 MP4s within 1920 by 1080 and 1280 by 720, never enlarged, from one read of the input.
One job with several outputs fetches the input once and is billed once for its bytes, so it costs less than one job per size.
One size#
Set width or height alone to keep the shape; the other side follows and stays even, as H.264
needs.
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/talk.mp4",
"filename": "talk-480p.mp4",
"resize": {
"height": 480
}
}'Copy failed. The text is selected; copy it with your keyboard.
const response = await fetch(`${process.env.VIDEXO_API_URL}/v1/transcode`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDEXO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "https://example.com/talk.mp4",
"filename": "talk-480p.mp4",
"resize": {
"height": 480
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-map 0:v:0 \
-vf scale=7680:480:force_original_aspect_ratio=decrease:force_divisible_by=2 \
-c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
-map "0:a:0?" \
-c:a aac -b:a 128k -movflags +faststart \
talk-480p.mp4Copy failed. The text is selected; copy it with your keyboard.
A box: contain, cover or pad#
With both width and height, fit decides what happens when the shapes differ: contain (the
default) fits the whole picture inside the box, cover fills the box and crops the overflow at
anchor, pad fits the picture and fills the rest with pad_color.
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/talk.mp4",
"filename": "talk-card.mp4",
"resize": {
"width": 1200,
"height": 628,
"fit": "cover",
"anchor": "top"
}
}'Copy failed. The text is selected; copy it with your keyboard.
const response = await fetch(`${process.env.VIDEXO_API_URL}/v1/transcode`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDEXO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "https://example.com/talk.mp4",
"filename": "talk-card.mp4",
"resize": {
"width": 1200,
"height": 628,
"fit": "cover",
"anchor": "top"
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-map 0:v:0 \
-vf "scale=1200:628:force_original_aspect_ratio=increase,crop=1200:628:(iw-ow)/2:0" \
-c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
-map "0:a:0?" \
-c:a aac -b:a 128k -movflags +faststart \
talk-card.mp4Copy failed. The text is selected; copy it with your keyboard.
Never larger than the input#
resize enlarges a smaller input to the size you set, unless enlarge is false: then an input
larger than the size is scaled down and a smaller one keeps its own size.
curl "$VIDEXO_API_URL/v1/transcode" \
-H "Authorization: Bearer $VIDEXO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "https://example.com/talk.mp4",
"filename": "talk-max-1080p.mp4",
"resize": {
"width": 1920,
"height": 1080,
"enlarge": false
}
}'Copy failed. The text is selected; copy it with your keyboard.
const response = await fetch(`${process.env.VIDEXO_API_URL}/v1/transcode`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDEXO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input": "https://example.com/talk.mp4",
"filename": "talk-max-1080p.mp4",
"resize": {
"width": 1920,
"height": 1080,
"enlarge": false
}
}),
});
const job = await response.json();Copy failed. The text is selected; copy it with your keyboard.
ffmpeg \
-i https://example.com/talk.mp4 \
-map 0:v:0 \
-vf "scale='min(iw,1920)':'min(ih,1080)':force_original_aspect_ratio=decrease:force_divisible_by=2" \
-c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
-map "0:a:0?" \
-c:a aac -b:a 128k -movflags +faststart \
talk-max-1080p.mp4Copy failed. The text is selected; copy it with your keyboard.
Operations has every resize field.