Back to feed
Dev.to
Dev.to
7/25/2026
Your YouTube screenshot is black because you screenshotted the wrong layer

Your YouTube screenshot is black because you screenshotted the wrong layer

Short summary

Hardware-accelerated video doesn't paint into the same surface as the rest of the browser window, so PrintScreen yields a black rectangle. The fix is to use canvas drawImage on the <video> element directly, reading the decoded frame at full resolution via videoWidth/videoHeight. The author also ships a Chrome extension (Screenshot for YouTube) that wraps this approach with player UI integration, clipboard support, and DRM-error handling.

  • Black screenshots happen because hardware-accelerated video uses a separate rendering surface
  • Use canvas drawImage(video) to capture the actual decoded frame at native resolution
  • Watch for DRM-protected streams (drawImage throws), clipboard PNG-only constraint, and user-gesture requirements

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more