Addressing Webcam Video Blinking and Desynchronization in Browser-Based Screen Recordings
Developing a seamless browser-based screen recorder that captures both the desktop and webcam feeds simultaneously can be quite challenging. I’ve been working on such a tool using Next.js, leveraging the MediaStream and MediaRecorder APIs to combine various media sources into a cohesive recording.
The Setup
My approach involves merging the screen and webcam streams onto an HTML5 canvas element. This canvas rendering provides a unified visual output, which I then record using the MediaRecorder API. Additionally, I include audio sources, such as system sounds and background music, capturing everything in real-time.
The Experience
While the preview appears smooth with synchronized video and audio, issues surface during post-processing. Once exported, the webcam footage sometimes exhibits blinking, goes completely black temporarily, or falls out of sync with the main screen recording.
What I’ve Tried
- Attempting to synchronize stream playback times via
.currentTimeadjustments - Leveraging
requestAnimationFrame()for controlled rendering precision - Waiting for streams to seek (
waitForSeek()) before initiating playback - Performing frame-by-frame rendering; however, this approach introduces performance bottlenecks
- Testing with various AI models and media sources to rule out external influences
Here’s a simplified demonstration of my current implementation for reference: View Code
Queries and Insights
I’m reaching out to the community with a couple of questions:
- Have others encountered similar issues of blinking or desynchronization when recording combined streams using MediaRecorder?
- Are there known limitations or best practices for handling multiple media sources, particularly with
canvascompositing and MediaRecorder?
I’m not requesting specific code modifications but would greatly appreciate insights based on your experiences. If anyone has faced similar challenges or knows workarounds—whether related to stream synchronization, MediaRecorder nuances, or browser behavior—your advice would be invaluable.
Thanks in advance for sharing your expertise and helping troubleshoot these tricky video recording quirks!

