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.
Job Lifecycle
Section titled “Job Lifecycle”- Created - Job is queued for processing
- Started - Processing begins
- Completed - Processing finished successfully
- Failed - Processing encountered an error
Job Types
Section titled “Job Types”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
Tracking Jobs
Section titled “Tracking Jobs”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}`); }, },});
Querying Jobs
Section titled “Querying Jobs”Get job status and history:
// Get all jobsconst jobs = await client.jobs().fetch();
// Get failed jobs for debuggingconst failedJobs = await client .from("jobs") .select("id", "content", "status", "created_at") .where("status", "=", "failed") .fetch();
// Get jobs for a specific objectconst objectJobs = await client .from("jobs") .select() .where("content->>'object_id'", "=", "your-object-id") .fetch();
Job Structure
Section titled “Job Structure”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" }}
WebSocket Events
Section titled “WebSocket Events”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; } },});
Error Handling
Section titled “Error Handling”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 }, },});
Processing Times
Section titled “Processing Times”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.