Matthew Gatland

How to make YouTube (or other video websites) louder

November 24, 2017

Sometimes I find a YouTube video of a conference talk that’s just too quiet. Even when it’s set to maximum volume, with Windows set to maximum volume, it’s still too quiet.

The YouTube volume slider set to maximum

The Windows volume slider set to maximum

You can easily fix this with JavaScript!

First, open your web browser’s JavaScript console. In Chrome, click on the menu button, then ‘more tools’, then ‘Developer Tools’ to open the developer tools.

Opening the developer tools as described above

In the Developer Tools, click on the Console tab.

Open the console

Click in the empty white space after the > symbol. Now you can type or paste code into the console.

Click on the console

Copy this code and paste it into the console.

var videoElement = document.querySelector("video")
var audioCtx = new AudioContext()
var source = audioCtx.createMediaElementSource(videoElement)
var gainNode = audioCtx.createGain()
gainNode.gain.value = 2 // double the volume
source.connect(gainNode)
gainNode.connect(audioCtx.destination)

It will look like this once you paste it in:

The code, as it will appear in the console.

Press enter to send the code to your browser. The video should immediately get louder.

If you want to make it even louder, copy this line, paste it in and press enter. You can change the number to a higher value to make it even louder.

gainNode.gain.value = 3

The code, as it will appear in the console.

What just happened?

Imagine that the video was a physical object (like a phone), and it was connected to your speakers by a cable.

We unplugged that cable and connected the video to a new object called a gain node. Then we plugged the gain node into your speakers. Sound flows from the video to the gain node to the speakers. The gain node has a volume dial on it, and we can adjust that dial to amplify the sound.