Files

Upload video, audio, image, and caption files for use in compositions and renders.

Files are uploaded in two steps: upload the raw bytes, then wait for processing.

Upload a file

const fileBytes = await fs.readFile("clip.mp4");

const res = await fetch("https://api.editframe.com/api/v1/files", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.EDITFRAME_API_KEY}`,
    "Content-Type": "video/mp4",
    "X-Filename": "clip.mp4",
  },
  body: fileBytes,
});

const file = await res.json();
// { id: "fil_abc123", status: "processing", ... }

Poll until ready

async function waitForFile(id) {
  while (true) {
    const res = await fetch(`https://api.editframe.com/api/v1/files/${id}`, {
      headers: { Authorization: `Bearer ${process.env.EDITFRAME_API_KEY}` },
    });
    const file = await res.json();

    if (file.status === "ready") return file;
    if (file.status === "failed") throw new Error(`File processing failed: ${id}`);

    await new Promise((r) => setTimeout(r, 1000));
  }
}

const file = await waitForFile("fil_abc123");

File status values

StatusDescription
processingFile received, being transcoded or indexed
readyFile is available for use
failedProcessing failed

Using a file in a composition

Once a file is ready, generate a signed URL via the URL Signing endpoint and use it as a src:

<ef-video src="https://cdn.editframe.com/files/fil_abc123?token=..."></ef-video>

Caption files

Caption files follow the same upload pipeline. The file must be the JSON format produced by the transcribe CLI command. Use the resulting signed URL as the src for ef-captions:

<ef-captions src="https://cdn.editframe.com/files/fil_abc123?token=..."></ef-captions>