Reel de propiedad con tus fotos
En esta página
Las fotos de una propiedad se convierten en un reel vertical: cada foto recibe un acercamiento o paneo lento, la dirección y el precio abren el reel y una tarjeta de contacto lo cierra. El Agente de OneUpAI que los hace recibe de 4 a 40 fotos, un logotipo, la foto del agente inmobiliario, música opcional y un guion cuyas líneas nombran números de foto. Al terminar esta página sabrás cada llamada que hace y el Timeline que envía.
Cuánto cuesta #
Solo se cobra el render final: 15 créditos por cada 10 segundos de video iniciados. Diez fotos de 3 segundos cada una, unidas por fundidos de 0,4 segundos, y luego una tarjeta de cierre de 4 segundos dan un reel de 30 segundos: 3 bloques, 45 créditos, cerca de 0,46 US$. La vista previa es gratis.
Las duraciones son metas, no muros. Un guion más largo alarga el reel y cobra el bloque de 10 segundos extra. Solo se rechaza un video que pase el límite de duración (3 minutos hoy), con su nombre, antes de cobrar nada.
Las llamadas, en orden #
POST /v1/uploads/initiate × una por foto, el logotipo, la foto del agente y el archivo de música → envía los bytes con PUT a cada upload_url
POST /v1/projects {"agent_slug": "oneup/render-timeline"} → {"project_id"}
PUT /v1/projects/{project_id}/timeline {"timeline": <el Timeline de abajo>} → {"version_id"}
POST /v1/renders (Idempotency-Key) {"alias": "oneup/render-timeline", "project_id", "version_id", "kind": "preview"}
POST /v1/renders (Idempotency-Key) {"alias": "oneup/render-timeline", "project_id", "version_id", "kind": "final"}
GET /v1/renders/{render_id} → {"status": "COMPLETED", "ticket", …}
GET /v1/queue/result/{ticket} → {"assets": [el MP4]}Ejecútalo tiene estas llamadas como un programa en cada lenguaje.
El Timeline #
Cada foto es un segmento con un movimiento Ken Burns (acercamiento y paneo se alternan) y un fundido hacia la siguiente. El último segmento se desvanece: en el último segmento no se permite una transición, así que el desvanecido es un efecto. Un texto sobre el video nombra la dirección y el precio, el logotipo queda en una esquina y una música de fondo se repite debajo de todo.
<total ms> es la duración del reel en milisegundos: la suma de las duraciones de los segmentos, menos la duración de cada fundido, porque un fundido se superpone a las dos fotos que une. Cada range debe terminar antes de ese momento.
{
"v": "1.1",
"output": { "aspect": "9:16", "resolution": 1080, "fps": 30, "container": "mp4" },
"segments": [
{ "id": "p1", "source": { "$asset": "<id de la subida de la foto 1>" }, "duration": 3000,
"effects": [{ "op": "kenburns", "from": { "x": 0.5, "y": 0.5, "zoom": 1 },
"to": { "x": 0.5, "y": 0.5, "zoom": 1.18 }, "ease": "ease_in_out" }],
"transition_out": { "op": "crossfade", "duration": 400 } },
{ "id": "p2", "source": { "$asset": "<id de la subida de la foto 2>" }, "duration": 3000,
"effects": [{ "op": "kenburns", "from": { "x": 0.58, "y": 0.5, "zoom": 1.18 },
"to": { "x": 0.42, "y": 0.5, "zoom": 1.18 }, "ease": "ease_in_out" }],
"transition_out": { "op": "crossfade", "duration": 400 } },
"… un segmento por foto, alternando acercamiento y paneo …",
{ "id": "card", "source": { "$asset": "<id de la subida de la última foto>" }, "duration": 4000,
"effects": [{ "op": "fade", "from": 1, "to": 0, "duration": 600 }] }
],
"overlays": [
{ "id": "logo", "kind": "image", "source": { "$asset": "<id de la subida del logotipo>" },
"position": { "x": 0.05, "y": 0.028 }, "scale": 0.12, "range": { "from": 0, "to": <total ms> } },
{ "id": "t1", "kind": "text", "content": "14 Maple Lane, Oakridge", "style": "lower_third",
"position": "middle", "range": { "from": 0, "to": 3000 },
"enter": { "op": "fade", "duration": 250 }, "exit": { "op": "fade", "duration": 200 } },
{ "id": "t2", "kind": "text", "content": "$849,000 · 3 bd · 2.5 ba", "style": "lower_third",
"position": "bottom", "range": { "from": 0, "to": 3000 } },
"… un texto por línea del guion, sobre la foto que nombra …"
],
"audio": [
{ "id": "bed", "role": "music", "source": { "$asset": "<id de la subida de la música>" },
"range": { "from": 0, "to": <total ms> }, "loop": true, "gain": -14,
"fade_in": 600, "fade_out": 600 }
]
}Ejecútalo #
Cada versión es un programa, que se muestra completo abajo y se puede descargar de la carpeta de ejemplos: run.sh (curl y jq), run.mts (Node.js 20 o más nuevo: npx tsx run.mts) y run.py (Python 3.8 o más nuevo: python3 run.py). Cada uno hace las llamadas de arriba en orden, imprime cada respuesta y se detiene en la primera llamada que se rechace. Pon los archivos que usa en la carpeta desde donde lo ejecutas: las fotos como photo-1.jpg, photo-2.jpg y así, en el orden en que se ven, tu logo como logo.png y la música como music.mp3.
#!/usr/bin/env bash
# Listing reel from your photos: a property's photos become a vertical reel,
# each with a slow push-in or pan, the address and price over the opening, a
# logo in the corner, a music bed, and a closing card. A 30-second reel from
# ten photos is 45 credits; the Preview is free.
# The calls of the page https://api.oneupai.com/docs/recipes/listing-reel, in
# its order, as one program.
#
# In the folder you run it from: the photos as photo-1.jpg, photo-2.jpg, … (in
# the order they should play; the page's Agent takes 4 to 40), your logo as
# logo.png and the music as music.mp3. Change ADDRESS, DETAILS and LINES below.
#
# export ONEUP_API_KEY="oneup_live_…" # your Builder key
# bash run.sh
#
# Needs curl, jq and uuidgen. ONEUP_BASE_URL changes the host (default
# https://api.oneupai.com). Every answer is printed as it arrives.
set -euo pipefail
: "${ONEUP_API_KEY:?Set ONEUP_API_KEY to your API key first}"
API=${ONEUP_BASE_URL:-https://api.oneupai.com}
ADDRESS="14 Maple Lane, Oakridge"
DETAILS='$849,000 · 3 bd · 2.5 ba'
# Script lines: [photo number, words shown over that photo].
LINES='[[2, "Sunlit kitchen with an island"], [3, "Primary suite with a view"]]'
# One API call; the answer is printed and kept in OUT. A refusal stops here.
api() {
local method=$1 path=$2
shift 2
OUT=$(curl -sS -X "$method" "$API$path" \
-H "Authorization: Bearer $ONEUP_API_KEY" \
-H "Content-Type: application/json" "$@")
echo "$OUT"
if ! echo "$OUT" | jq -e 'type == "object" and (has("error") | not)' > /dev/null; then
echo "refused: $method $path" >&2
exit 1
fi
}
# Uploads one file; its upload id is left in UPLOAD.
upload() {
local file=$1 type=$2 size
size=$(wc -c < "$file" | tr -d ' ')
api POST /v1/uploads/initiate -d "$(jq -n --arg t "$type" --arg n "$file" --argjson s "$size" \
'{content_type: $t, file_name: $n, size_bytes: $s}')"
UPLOAD=$(echo "$OUT" | jq -r .upload_id)
curl -sS -f -X PUT "$(echo "$OUT" | jq -r .upload_url)" \
-H "Content-Type: $type" --data-binary @"$file" > /dev/null
}
# Starts a render, waits for it, and leaves the finished render in OUT.
render() {
api POST /v1/renders -H "Idempotency-Key: $(uuidgen)" \
-d "$(jq -n --arg p "$PROJECT" --arg v "$VERSION" --arg k "$1" \
'{alias: "oneup/render-timeline", project_id: $p, version_id: $v, kind: $k}')"
local id
id=$(echo "$OUT" | jq -r .render_id)
until echo "$OUT" | jq -e '.status == "COMPLETED" or .status == "FAILED"' > /dev/null; do
sleep 5
api GET "/v1/renders/$id"
done
}
ls photo-*.jpg > /dev/null 2>&1 || { echo "no photo-*.jpg in this folder" >&2; exit 1; }
PHOTOS='[]'
for file in $(printf '%s\n' photo-*.jpg | sort -t- -k2 -n); do
upload "$file" image/jpeg
PHOTOS=$(echo "$PHOTOS" | jq -c --arg id "$UPLOAD" '. + [$id]')
done
upload logo.png image/png
LOGO=$UPLOAD
upload music.mp3 audio/mpeg
MUSIC=$UPLOAD
api POST /v1/projects -d '{"agent_slug": "oneup/render-timeline"}'
PROJECT=$(echo "$OUT" | jq -r .project_id)
# Each photo is 3 s, joined by 0.4 s crossfades; the card is 4 s. The reel's
# length is the durations added up, minus each crossfade.
TIMELINE=$(jq -n --argjson photos "$PHOTOS" --arg logo "$LOGO" --arg music "$MUSIC" \
--arg address "$ADDRESS" --arg details "$DETAILS" --argjson lines "$LINES" '
($photos | length) as $n
| ($n * 3000 + 4000 - $n * 400) as $total
| {
v: "1.1",
output: {aspect: "9:16", resolution: 1080, fps: 30, container: "mp4"},
segments: ([$photos | to_entries[] | {
id: "p\(.key + 1)",
source: {"$asset": .value},
duration: 3000,
effects: [if .key % 2 == 0
then {op: "kenburns", from: {x: 0.5, y: 0.5, zoom: 1}, to: {x: 0.5, y: 0.5, zoom: 1.18}, ease: "ease_in_out"}
else {op: "kenburns", from: {x: 0.58, y: 0.5, zoom: 1.18}, to: {x: 0.42, y: 0.5, zoom: 1.18}, ease: "ease_in_out"}
end],
transition_out: {op: "crossfade", duration: 400}
}]
+ [{id: "card", source: {"$asset": $photos[-1]}, duration: 4000,
effects: [{op: "fade", from: 1, to: 0, duration: 600}]}]),
overlays: ([
{id: "logo", kind: "image", source: {"$asset": $logo},
position: {x: 0.05, y: 0.028}, scale: 0.12, range: {from: 0, to: $total}},
{id: "t1", kind: "text", content: $address, style: "lower_third",
position: "middle", range: {from: 0, to: 3000},
enter: {op: "fade", duration: 250}, exit: {op: "fade", duration: 200}},
{id: "t2", kind: "text", content: $details, style: "lower_third",
position: "bottom", range: {from: 0, to: 3000}}
]
+ [$lines[] | select(.[0] >= 2 and .[0] <= $n) | {
id: "line\(.[0])", kind: "text", content: .[1], style: "lower_third",
position: "bottom",
range: {from: ((.[0] - 1) * 2600 + 400), to: ((.[0] - 1) * 2600 + 3000)}
}]),
audio: [{id: "bed", role: "music", source: {"$asset": $music},
range: {from: 0, to: $total}, loop: true, gain: -14,
fade_in: 600, fade_out: 600}]
}')
api PUT "/v1/projects/$PROJECT/timeline" -d "$(jq -n --argjson t "$TIMELINE" '{timeline: $t}')"
VERSION=$(echo "$OUT" | jq -r .version_id)
render preview
render final
api GET "/v1/queue/result/$(echo "$OUT" | jq -r .ticket)"// Listing reel from your photos: a property's photos become a vertical reel,
// each with a slow push-in or pan, the address and price over the opening, a
// logo in the corner, a music bed, and a closing card. A 30-second reel from
// ten photos is 45 credits; the Preview is free.
// The calls of the page https://api.oneupai.com/docs/recipes/listing-reel, in
// its order, as one program.
//
// In the folder you run it from: the photos as photo-1.jpg, photo-2.jpg, … (in
// the order they should play; the page's Agent takes 4 to 40), your logo as
// logo.png and the music as music.mp3. Change ADDRESS, DETAILS and LINES below.
//
// export ONEUP_API_KEY="oneup_live_…" # your Builder key
// npx tsx run.mts # Node.js 20 or newer
//
// ONEUP_BASE_URL changes the host (default https://api.oneupai.com). Every
// answer is printed as it arrives.
import { readFile, readdir } from "node:fs/promises";
const API = process.env.ONEUP_BASE_URL ?? "https://api.oneupai.com";
const KEY = process.env.ONEUP_API_KEY;
if (!KEY) throw new Error("Set ONEUP_API_KEY to your API key first");
const ADDRESS = "14 Maple Lane, Oakridge";
const DETAILS = "$849,000 · 3 bd · 2.5 ba";
// Script lines: [photo number, words shown over that photo].
const LINES: [number, string][] = [
[2, "Sunlit kitchen with an island"],
[3, "Primary suite with a view"],
];
// One API call: the answer is printed and returned; a refusal stops here.
async function call(
method: string,
path: string,
body?: object,
headers?: Record<string, string>
) {
const res = await fetch(API + path, {
signal: AbortSignal.timeout(60_000),
method,
headers: {
Authorization: `Bearer ${KEY}`,
"Content-Type": "application/json",
...headers,
},
body: body && JSON.stringify(body),
});
const json = await res.json();
console.log(JSON.stringify(json));
if (!res.ok) throw new Error(`${res.status} ${json.error}: ${json.message}`);
return json;
}
async function upload(file: string, type: string): Promise<string> {
const bytes = await readFile(file);
const target = await call("POST", "/v1/uploads/initiate", {
content_type: type,
file_name: file,
size_bytes: bytes.length,
});
const put = await fetch(target.upload_url, {
signal: AbortSignal.timeout(300_000),
method: "PUT",
headers: { "Content-Type": type },
body: bytes,
});
if (!put.ok) throw new Error(`${file}: the upload answered ${put.status}`);
return target.upload_id;
}
async function render(projectId: string, versionId: string, kind: string) {
let r = await call(
"POST",
"/v1/renders",
{
alias: "oneup/render-timeline",
project_id: projectId,
version_id: versionId,
kind,
},
{ "Idempotency-Key": crypto.randomUUID() }
);
const renderId = r.render_id;
while (r.status !== "COMPLETED" && r.status !== "FAILED") {
await new Promise((resolve) => setTimeout(resolve, 5000));
r = await call("GET", `/v1/renders/${renderId}`);
}
return r;
}
const files = (await readdir("."))
.filter((f) => /^photo-\d+\.jpg$/.test(f))
.sort((a, b) => parseInt(a.slice(6)) - parseInt(b.slice(6)));
if (!files.length) throw new Error("no photo-*.jpg in this folder");
const photos: string[] = [];
for (const file of files) photos.push(await upload(file, "image/jpeg"));
const logo = await upload("logo.png", "image/png");
const music = await upload("music.mp3", "audio/mpeg");
const project = await call("POST", "/v1/projects", {
agent_slug: "oneup/render-timeline",
});
const projectId = project.project_id;
// Each photo is 3 s, joined by 0.4 s crossfades; the card is 4 s. The reel's
// length is the durations added up, minus each crossfade.
const n = photos.length;
const total = n * 3000 + 4000 - n * 400;
const pushIn = {
op: "kenburns",
from: { x: 0.5, y: 0.5, zoom: 1 },
to: { x: 0.5, y: 0.5, zoom: 1.18 },
ease: "ease_in_out",
};
const pan = {
op: "kenburns",
from: { x: 0.58, y: 0.5, zoom: 1.18 },
to: { x: 0.42, y: 0.5, zoom: 1.18 },
ease: "ease_in_out",
};
const timeline = {
v: "1.1",
output: { aspect: "9:16", resolution: 1080, fps: 30, container: "mp4" },
segments: [
...photos.map((id, i) => ({
id: `p${i + 1}`,
source: { $asset: id },
duration: 3000,
effects: [i % 2 === 0 ? pushIn : pan],
transition_out: { op: "crossfade", duration: 400 },
})),
{
id: "card",
source: { $asset: photos[n - 1] },
duration: 4000,
effects: [{ op: "fade", from: 1, to: 0, duration: 600 }],
},
],
overlays: [
{
id: "logo",
kind: "image",
source: { $asset: logo },
position: { x: 0.05, y: 0.028 },
scale: 0.12,
range: { from: 0, to: total },
},
{
id: "t1",
kind: "text",
content: ADDRESS,
style: "lower_third",
position: "middle",
range: { from: 0, to: 3000 },
enter: { op: "fade", duration: 250 },
exit: { op: "fade", duration: 200 },
},
{
id: "t2",
kind: "text",
content: DETAILS,
style: "lower_third",
position: "bottom",
range: { from: 0, to: 3000 },
},
...LINES.filter(([photo]) => photo >= 2 && photo <= n).map(
([photo, words]) => ({
id: `line${photo}`,
kind: "text",
content: words,
style: "lower_third",
position: "bottom",
range: {
from: (photo - 1) * 2600 + 400,
to: (photo - 1) * 2600 + 3000,
},
})
),
],
audio: [
{
id: "bed",
role: "music",
source: { $asset: music },
range: { from: 0, to: total },
loop: true,
gain: -14,
fade_in: 600,
fade_out: 600,
},
],
};
const version = await call("PUT", `/v1/projects/${projectId}/timeline`, {
timeline,
});
await render(projectId, version.version_id, "preview");
const final = await render(projectId, version.version_id, "final");
await call("GET", `/v1/queue/result/${final.ticket}`);#!/usr/bin/env python3
# Listing reel from your photos: a property's photos become a vertical reel,
# each with a slow push-in or pan, the address and price over the opening, a
# logo in the corner, a music bed, and a closing card. A 30-second reel from
# ten photos is 45 credits; the Preview is free.
# The calls of the page https://api.oneupai.com/docs/recipes/listing-reel, in
# its order, as one program.
#
# In the folder you run it from: the photos as photo-1.jpg, photo-2.jpg, ... (in
# the order they should play; the page's Agent takes 4 to 40), your logo as
# logo.png and the music as music.mp3. Change ADDRESS, DETAILS and LINES below.
#
# export ONEUP_API_KEY="oneup_live_..." # your Builder key
# python3 run.py # Python 3.8 or newer
#
# ONEUP_BASE_URL changes the host (default https://api.oneupai.com). Every
# answer is printed as it arrives. Standard library only.
import glob, json, os, time, urllib.error, urllib.request, uuid
API = os.environ.get("ONEUP_BASE_URL", "https://api.oneupai.com")
KEY = os.environ["ONEUP_API_KEY"]
# The default Python User-Agent is refused before a request reaches the API;
# any name for your app works.
AGENT = "my-app/1.0"
ADDRESS = "14 Maple Lane, Oakridge"
DETAILS = "$849,000 · 3 bd · 2.5 ba"
# Script lines: (photo number, words shown over that photo).
LINES = [(2, "Sunlit kitchen with an island"), (3, "Primary suite with a view")]
def call(method, path, body=None, headers=None):
"""One API call: the answer is printed and returned; a refusal stops here."""
request = urllib.request.Request(
API + path,
method=method,
data=None if body is None else json.dumps(body).encode(),
headers={
"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json",
"User-Agent": AGENT,
**(headers or {}),
},
)
try:
with urllib.request.urlopen(request, timeout=60) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
problem = json.load(error)
print(json.dumps(problem))
raise SystemExit(f"{error.code} {problem['error']}: {problem['message']}")
print(json.dumps(answer))
return answer
def upload(name, content_type):
with open(name, "rb") as file:
data = file.read()
target = call(
"POST",
"/v1/uploads/initiate",
{"content_type": content_type, "file_name": name, "size_bytes": len(data)},
)
put = urllib.request.Request(
target["upload_url"],
method="PUT",
data=data,
headers={"Content-Type": content_type, "User-Agent": AGENT},
)
urllib.request.urlopen(put, timeout=300).close()
return target["upload_id"]
def render(project_id, version_id, kind):
r = call(
"POST",
"/v1/renders",
{
"alias": "oneup/render-timeline",
"project_id": project_id,
"version_id": version_id,
"kind": kind,
},
{"Idempotency-Key": str(uuid.uuid4())},
)
render_id = r["render_id"]
while r["status"] not in ("COMPLETED", "FAILED"):
time.sleep(5)
r = call("GET", f"/v1/renders/{render_id}")
return r
files = sorted(glob.glob("photo-*.jpg"), key=lambda f: int(f[6:-4]))
if not files:
raise SystemExit("no photo-*.jpg in this folder")
photos = [upload(f, "image/jpeg") for f in files]
logo = upload("logo.png", "image/png")
music = upload("music.mp3", "audio/mpeg")
project = call("POST", "/v1/projects", {"agent_slug": "oneup/render-timeline"})
project_id = project["project_id"]
# Each photo is 3 s, joined by 0.4 s crossfades; the card is 4 s. The reel's
# length is the durations added up, minus each crossfade.
n = len(photos)
total = n * 3000 + 4000 - n * 400
push_in = {
"op": "kenburns",
"from": {"x": 0.5, "y": 0.5, "zoom": 1},
"to": {"x": 0.5, "y": 0.5, "zoom": 1.18},
"ease": "ease_in_out",
}
pan = {
"op": "kenburns",
"from": {"x": 0.58, "y": 0.5, "zoom": 1.18},
"to": {"x": 0.42, "y": 0.5, "zoom": 1.18},
"ease": "ease_in_out",
}
segments = [
{
"id": f"p{i + 1}",
"source": {"$asset": photo},
"duration": 3000,
"effects": [push_in if i % 2 == 0 else pan],
"transition_out": {"op": "crossfade", "duration": 400},
}
for i, photo in enumerate(photos)
]
segments.append(
{
"id": "card",
"source": {"$asset": photos[-1]},
"duration": 4000,
"effects": [{"op": "fade", "from": 1, "to": 0, "duration": 600}],
}
)
overlays = [
{
"id": "logo",
"kind": "image",
"source": {"$asset": logo},
"position": {"x": 0.05, "y": 0.028},
"scale": 0.12,
"range": {"from": 0, "to": total},
},
{
"id": "t1",
"kind": "text",
"content": ADDRESS,
"style": "lower_third",
"position": "middle",
"range": {"from": 0, "to": 3000},
"enter": {"op": "fade", "duration": 250},
"exit": {"op": "fade", "duration": 200},
},
{
"id": "t2",
"kind": "text",
"content": DETAILS,
"style": "lower_third",
"position": "bottom",
"range": {"from": 0, "to": 3000},
},
]
for photo, words in LINES:
if 2 <= photo <= n:
start = (photo - 1) * 2600
overlays.append(
{
"id": f"line{photo}",
"kind": "text",
"content": words,
"style": "lower_third",
"position": "bottom",
"range": {"from": start + 400, "to": start + 3000},
}
)
timeline = {
"v": "1.1",
"output": {"aspect": "9:16", "resolution": 1080, "fps": 30, "container": "mp4"},
"segments": segments,
"overlays": overlays,
"audio": [
{
"id": "bed",
"role": "music",
"source": {"$asset": music},
"range": {"from": 0, "to": total},
"loop": True,
"gain": -14,
"fade_in": 600,
"fade_out": 600,
}
],
}
version = call("PUT", f"/v1/projects/{project_id}/timeline", {"timeline": timeline})
render(project_id, version["version_id"], "preview")
final = render(project_id, version["version_id"], "final")
call("GET", f"/v1/queue/result/{final['ticket']}")