Skip to content

Background Jobs

Zapdos uses background jobs to process your uploaded files. When you upload a video, jobs handle indexing, scene extraction, transcription, and other AI processing tasks.

  1. Created - Job is queued for processing
  2. Started - Processing begins
  3. Completed - Processing finished successfully
  4. Failed - Processing encountered an error

Different types of background jobs:

  • Indexing - Analyzes video content and extracts scenes
  • Transcription - Converts speech to text with timestamps
  • Thumbnail generation - Creates scene preview images
  • Metadata extraction - Extracts file information

Monitor job progress through callbacks:

await client.upload("./video.mp4", {
job: {
onIndexingStarted: ({ object_id, job_id }) => {
console.log(`Started processing ${object_id}`);
},
onIndexingCompleted: ({ object_id, job_id }) => {
console.log(`Processing complete for ${object_id}`);
console.log("Video is now searchable!");
},
onIndexingFailed: ({ object_id, job_id }) => {
console.error(`Processing failed for ${object_id}`);
},
},
});

Get job status and history:

// Get all jobs
const jobs = await client.jobs().fetch();
// Get failed jobs for debugging
const failedJobs = await client
.from("jobs")
.select("id", "content", "status", "created_at")
.where("status", "=", "failed")
.fetch();
// Get jobs for a specific object
const objectJobs = await client
.from("jobs")
.select()
.where("content->>'object_id'", "=", "your-object-id")
.fetch();

Each job contains:

{
id: "job-id-123",
created_at: "2025-01-15T10:30:00Z",
org_id: "your-org-id",
status: "completed", // started, processing, completed, failed
content: {
object_id: "object-id-123",
type: "indexing"
}
}

Listen to real-time job updates:

const ws = client.listen({
onMessage: (data) => {
switch (data.type) {
case "indexing_started":
console.log(`Job started: ${data.job_id}`);
break;
case "indexing_completed":
console.log(`Job completed: ${data.job_id}`);
break;
case "indexing_failed":
console.log(`Job failed: ${data.job_id}`);
break;
}
},
});

Handle job failures gracefully:

await client.upload("./video.mp4", {
job: {
onIndexingFailed: ({ object_id, job_id }) => {
// File uploaded successfully but processing failed
console.error("Processing failed - file is stored but not searchable");
// You could implement retry logic here
// or notify the user about the issue
},
},
});

Typical processing times:

  • Small videos (< 100MB) - 1-5 minutes
  • Medium videos (100MB-1GB) - 5-20 minutes
  • Large videos (> 1GB) - 20+ minutes

Processing time depends on video length, resolution, and current system load. Jobs are processed asynchronously, so your upload completes immediately while processing happens in the background.