-
Notifications
You must be signed in to change notification settings - Fork 128
Description
Some people in this repo (#125, #91) and also others online have had this issue where the produced video/audio recording originating from JS' Media Capture and Streams API (which puppeteer-stream
uses internally) contains crackling noise.
For clarification: this has nothing to do with the puppeteer-stream
package!
I struggled with this issue myself for a few weeks, and learned potential reasons why the audio could be crackling and solutions. Hopefully I help you figure out a fix! 😄
1. Your CPU is bottlenecking
The no. 1 cause I found is something called "Buffer Underrun" or "Buffer Underflow". Simply put: A buffer underrun occurs when the CPU fails to deliver audio data to the playback buffer in time, causing the buffer to run out of data and resulting in crackling or stuttering noises in the audio. If you want to go more in-depth, look it up!
Reasons your CPU might be failing:
- CPU is throttled, happens a lot on VPS with shared (v)CPUs
- CPU is too weak to keep up
- CPU is damaged or worn out
Primary solutions
- Especially for VPS: use dedicated (v)CPUs where you're allowed 100% of usage on every core without being throttled or having to share with others
- Repair or upgrade your CPU or optimize your system for better performance.
- Increase buffer size to give the CPU more time to refill the audio buffer.
- Update your system's audio drivers
Also worth trying
- Close background apps to reduce CPU workload and prioritize audio processing.
- Enable audio processing priority in system or software settings.
- Lower audio quality settings to reduce the amount of data processed.
- Disable power-saving modes that might slow down the CPU.
- Use dedicated audio hardware to offload processing from the CPU. (this is a long stretch though, better off getting a better CPU)
Extra sources for confirmation
- https://www.youtube.com/watch?v=rn8fV11SUmo
- https://www.reddit.com/r/WeAreTheMusicMakers/comments/13groat/comment/jk1gtau/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button