Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Custom thumbnail upload succeeds but is not applied to YouTube Shorts

$
0
0

I’m uploading a custom thumbnail for a YouTube Shorts video using the YouTube Data API v3. The API response indicates success, but the uploaded thumbnail is not applied to the video.

if thumbnail_path:            try:                # Verify thumbnail meets requirements                img = Image.open(thumbnail_path)                logging.info(f"Verifying thumbnail dimensions: {img.size}")                if img.size != (720, 1280):                    logging.error(f"Invalid thumbnail dimensions: {img.size}. Expected: (720, 1280)")                    img.close()                    return video_id                img.close()                if os.path.getsize(thumbnail_path) > 2 * 1024 * 1024:                    logging.error("Thumbnail file size exceeds 2MB limit")                    return video_id                # Create MediaFileUpload object for thumbnail                thumbnail_media = MediaFileUpload(                    thumbnail_path,                    mimetype='image/jpeg',                    resumable=False                )                # Set thumbnail with proper request                thumbnail_response = self.youtube.thumbnails().set(                    videoId=video_id,                    media_body=thumbnail_media                ).execute()                if 'items' in thumbnail_response:                    logging.info(f"Thumbnail successfully set for video {video_id}")                    logging.info(f"Original thumbnail dimensions: 720x1280")                    logging.info(f"YouTube generated thumbnails: {thumbnail_response['items']}")                else:                    logging.warning(f"Thumbnail upload response missing items: {thumbnail_response}")                # Wait for thumbnail processing                time.sleep(10)  # Increased wait time            except Exception as e:                logging.error(f"Failed to upload thumbnail: {str(e)}")                logging.error(f"Thumbnail path: {thumbnail_path}")                logging.error(f"Video ID: {video_id}")                logging.error(f"Full error: {traceback.format_exc()}")

The uploaded thumbnail meets all the documented requirements:

  1. Dimensions: 1280x720
  2. File size: Less than 2MB
  3. Format: JPEG

Is this a limitation of YouTube Shorts, or is there something specific I need to do to apply a custom thumbnail to Shorts?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>