Skip to main content

Thumbnails

Thumbnails API

Generate custom thumbnails from your videos at any timestamp. HesedVid’s thumbnail generation system allows you to create high-quality thumbnails in any resolution, perfect for video previews, galleries, and user interfaces.

Overview

The Thumbnails API provides two main functionalities:

  • Generate Custom Thumbnails: Create thumbnails at specific timestamps with custom dimensions
  • Get Best Available Thumbnail: Retrieve the highest quality thumbnail for a video
  • Check Generation Status: Monitor thumbnail generation progress

Generate Custom Thumbnail

/{orgID}/videos/{publicID}/thumbnails

Generate a custom thumbnail from a specific timestamp in your video.

Path Parameters

ParameterTypeRequiredDescription
orgIDstringYesYour organization’s unique identifier
publicIDstringYesThe public ID of the video asset

Request Body

ParameterTypeRequiredDescription
widthint32YesThumbnail width in pixels (1-4096)
heightint32YesThumbnail height in pixels (1-4096)
timestampMsint32YesTimestamp in milliseconds (0 to video duration)

Response

{
"body": {
"jobId": "thumb_job_123456789abcdef",
"url": "https://worker.hesedvid.com/pubvid_AbCdEf/thumbnails/custom/12000_320x180.webp",
"status": "pending"
}
}

Example Request

Get Best Available Thumbnail

/{orgID}/videos/{publicID}/thumbnail

Retrieve the highest quality thumbnail available for a video.

Path Parameters

ParameterTypeRequiredDescription
orgIDstringYesYour organization’s unique identifier
publicIDstringYesThe public ID of the video asset

Response

{
"body": {
"url": "https://worker.hesedvid.com/pubvid_AbCdEf/thumbnails/custom/5000_640x360.webp",
"available": true,
"width": 640,
"height": 360
}
}

Example Request

Check Thumbnail Generation Status

/thumbnails/{jobID}

Monitor the progress of thumbnail generation jobs.

Path Parameters

ParameterTypeRequiredDescription
jobIDstringYesThe job ID returned from thumbnail generation

Response

{
"body": {
"status": "completed",
"url": "https://worker.hesedvid.com/pubvid_AbCdEf/thumbnails/custom/12000_320x180.webp"
}
}

Job Status Values

StatusDescription
pendingThumbnail generation is queued
processingThumbnail is being generated
completedThumbnail is ready and URL is available
failedGeneration failed (check error logs)

Example Request

Thumbnail Generation Process

How It Works

  1. Request Submission: Submit thumbnail generation request with dimensions and timestamp
  2. Job Creation: System creates a background job and returns job ID
  3. Processing: Worker processes the video frame at specified timestamp
  4. Storage: Generated thumbnail is stored in WebP format
  5. Delivery: Thumbnail is served via CDN for fast access

Supported Formats

  • Output Format: WebP (optimized for web delivery)
  • Dimensions: 1x1 to 4096x4096 pixels
  • Aspect Ratios: Any aspect ratio supported

Performance Considerations

  • Generation Time: Typically 2-10 seconds depending on video complexity
  • Concurrent Jobs: Up to 5 thumbnail jobs per organization
  • Caching: Generated thumbnails are cached indefinitely
  • CDN Delivery: Thumbnails served via global CDN for fast access

Best Practices

Thumbnail Dimensions

  • Video Galleries: 320x180 (16:9) or 240x135 (16:9)
  • Social Media: 1200x630 (Facebook) or 1200x675 (Twitter)
  • Mobile Apps: 640x360 or 480x270
  • High Quality: 1920x1080 for detailed previews

Timestamp Selection

  • Video Start: Use 0 for opening frame
  • Key Moments: Extract frames at important scenes
  • Midpoint: Use videoDurationMs / 2 for middle frame
  • Custom: Choose specific timestamps for branded content

Error Handling

const generateThumbnailWithRetry = async (videoId, options, maxRetries = 3) => {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await generateThumbnail(videoId, options);
// Poll for completion
let status = 'pending';
while (status === 'pending' || status === 'processing') {
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
const statusResponse = await checkThumbnailStatus(response.jobId);
status = statusResponse.status;
if (status === 'completed') {
return statusResponse.url;
} else if (status === 'failed') {
throw new Error('Thumbnail generation failed');
}
}
} catch (error) {
if (attempt === maxRetries) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * attempt)); // Exponential backoff
}
}
};

Common Use Cases

// Generate thumbnails for video gallery
const generateGalleryThumbnails = async (videos) => {
const thumbnails = await Promise.all(
videos.map(async (video) => {
const response = await generateThumbnail(video.publicId, {
width: 320,
height: 180,
timestampMs: 5000 // 5 seconds into video
});
return {
videoId: video.publicId,
thumbnailUrl: response.url,
jobId: response.jobId
};
})
);
return thumbnails;
};

Social Media Previews

// Generate social media optimized thumbnails
const generateSocialThumbnail = async (videoId) => {
const response = await generateThumbnail(videoId, {
width: 1200,
height: 630, // Facebook optimal size
timestampMs: 0 // Use opening frame
});
return response.url;
};

Mobile App Thumbnails

// Generate mobile-optimized thumbnails
const generateMobileThumbnail = async (videoId) => {
const response = await generateThumbnail(videoId, {
width: 640,
height: 360,
timestampMs: 10000 // 10 seconds into video
});
return response.url;
};

Error Handling

Common Errors

Status CodeErrorDescriptionSolution
400Bad RequestInvalid dimensions or timestampCheck width/height (1-4096) and timestamp (0 to video duration)
401UnauthorizedInvalid API keyVerify API key is correct and active
403ForbiddenVideo doesn’t belong to organizationEnsure video belongs to your organization
404Not FoundVideo not foundVerify video public ID is correct
422Unprocessable EntityTimestamp exceeds video durationUse timestamp within video length
429Too Many RequestsRate limit exceededWait before making more requests

Error Response Example

{
"title": "Bad Request",
"status": 400,
"detail": "Invalid thumbnail dimensions",
"errors": [
{
"message": "Width must be between 1 and 4096 pixels",
"location": "body.width",
"value": 5000
}
]
}

Rate Limits

OperationLimitWindow
Thumbnail generation50 requests1 hour
Status checks100 requests1 hour
Thumbnail retrieval1000 requests1 hour

Tip

Thumbnail generation is processed asynchronously. Use the job ID to poll for completion status rather than making repeated generation requests.