Skip to content

Instantly share code, notes, and snippets.

@matiaslopezd
Last active December 1, 2023 09:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiaslopezd/e715c9b5e69d4dbadb05027e11740ca7 to your computer and use it in GitHub Desktop.
Save matiaslopezd/e715c9b5e69d4dbadb05027e11740ca7 to your computer and use it in GitHub Desktop.
Amplify audio/video source Javascript
function amplify(node, gain) {
const audioCtx = new AudioContext();
const source = audioCtx.createMediaElementSource(node);
// create a gain node
const gainNode = audioCtx.createGain();
gainNode.gain.value = gain;
source.connect(gainNode);
// connect the gain node to an output destination
gainNode.connect(audioCtx.destination);
}
function amplify(node,gain){const audioCtx=new AudioContext();const source=audioCtx.createMediaElementSource(node);const gainNode=audioCtx.createGain();gainNode.gain.value=gain;source.connect(gainNode);gainNode.connect(audioCtx.destination)}
@matiaslopezd
Copy link
Author

Amplify audio or video

This script was used to amplifying the audio of videos on Netflix, HBO Max, Disney+, and Amazon Prime Video. The main reason to do it by Javascript and not by browser extension is that you cast a movie to the speaker like Google Home the volume could be low.

Below you will see how to use it in the most common platforms, but obviously, this could use it for other purposes.

How to use

  1. Copy the code of amplify.min.js or amplify.js.
  2. Go to the platform, press ctrl + shift + i (Windows, Linux, etc) or command + Option + j or right click and select Inspect.
  3. Open the tab Console and paste the code
  4. Copy the code of the platform where you want to use it
  5. Paste on Console and press Enter

By default the code will amplify 2 times the volume

const amplifier = 3; // Will amplify 3 times of volume
amplify(document.querySelector('video'), amplifier);

Caution: Not recommended set volume more than 5, could damage speakers or headphones.

Netflix, Disney+ and HBO Max

amplify(document.querySelector('video'));

Prime Video

const videos = document.querySelectorAll('video');
amplify(videos[videos.length - 1]);

Example in Netflix

function amplify(node, gain = 2) {
  const audioCtx = new AudioContext();
  const source = audioCtx.createMediaElementSource(node);

  // create a gain node
  const gainNode = audioCtx.createGain();
  gainNode.gain.value = gain;
  source.connect(gainNode);

  // connect the gain node to an output destination
  gainNode.connect(audioCtx.destination);
}
amplify(document.querySelector('video'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment