Urgent.News

What's breaking now, across thousands of outlets.

Tech

Keeping a browser video and a locally processed audio track in sync — and the 0.2s leak that broke it

We build [ HaramLite ]( https://haramlite.com ) , a desktop app that removes music and instrumentals from video and audio on the user's own machine — no uploads, no accounts, no cloud. This is the story of a sync bug in its browser side, because the fix is a nice illustration of a class of bug that is easy to ship and hard to see. ## The setup The browser extension never re-encodes anything. When…

The HaramLite desktop app removes music and instrumentals from video and audio on the user's own machine without any uploads or accounts. Its browser extension mutes the video and plays a separate audio file that keeps the two in sync. The audio is shorter than the video due to the removal of the instrumental sections. Whenever the video stretches without audio, the extension jumps the picture forward to match the audio timeline.

The issue occurred when the audio was repositioned only upon a seek landing inside a cut-out stretch. On regular jumps, the audio stayed in place while the picture moved for about 0.2 seconds. This caused listeners to hear the first word of the next sentence twice: once from the trailing end of the skipped section and again when the audio finally aligned correctly.

The app contains a periodic drift corrector that runs every second and fixes the audio if it drifts more than 0.35 seconds. However, the 0.2-second leak was within the allowed range, so it remained unnoticed and never corrected itself.

Two key aspects to address in the fix are: 1) computing the new audio position based on the seeked value rather than the element's current time, and 2) tightening the tolerance for the periodic corrector only during the jump, while maintaining a wider threshold for general use. These adjustments ensure the audio aligns correctly with the video, even after jumps or seeks.

The fix can be tested arithmetically, without relying on the browser. By extracting the pure mapping functions, one can demonstrate the correction without encountering browser-specific quirks or autoplay policies. In the given scenario, the audio drifted 0.20 seconds during the gap, which was not corrected due to the 0.35-second tolerance threshold.

However, the new re-anchor threshold of 0.05 seconds successfully corrected the audio position to the expected 10.00 seconds, demonstrating the effectiveness of the revised approach.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

You might want to check out my open source project called engrim.

If you are deep in utilizing AI services (CLI) and want access to a really powerful tool, you should explore my open source program called engrim.

  • Engrim is an open source project designed to enhance AI service utilization.
  • Features include seamless switching between AI providers and intelligent session context.
  • Engrim has gained 240 stars on GitHub, indicating its value and popularity.

More from Sunday 13 September →