https://github.com/tpkn/normalize-volume
Normalize audio using NodeJs and FFmpeg
https://github.com/tpkn/normalize-volume
Last synced: 11 months ago
JSON representation
Normalize audio using NodeJs and FFmpeg
- Host: GitHub
- URL: https://github.com/tpkn/normalize-volume
- Owner: tpkn
- License: mit
- Created: 2019-08-14T17:17:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-26T23:52:26.000Z (over 4 years ago)
- Last Synced: 2025-06-01T09:15:17.045Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 15
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Normalize Volume [](https://www.npmjs.org/package/normalize-volume)
Normalize audio using NodeJs and FFmpeg
## API
```javascript
await NormalizeVolume(input_file, output_file[, options])
```
### input_file
**Type**: _String_
Full path to source video file
### output_file
**Type**: _String_
Full path to future normalized video file
### options
**Type**: _Object_
### options.normalize
**Type**: _Boolean_
**Default**: `true`
Base on [Loudness Normalization](https://trac.ffmpeg.org/wiki/AudioVolume#LoudnessNormalization)
### options.volume
**Type**: _Number_
**Default**: `0.5`
Number starts with 0. Volume `0 = muted`, `2 = 200%`. Ignored if `normalize = true`
### options.ffmpeg_bin
**Type**: _String_
**Default**: `ffmpeg`
Path to [FFmpeg](http://ffmpeg.org/download.html) binary file
### options.convert_bin
**Type**: _String_
**Default**: `convert`
Path to [ImageMagick Convert](https://imagemagick.org/) binary file
### options.waveform
**Type**: _Object_
**Default**: `null`
Optional visualization of the normalization result. In short, it is a waveforms before and after normalization, merged together.

To customize waveform, use this options:
| Option | Type | Default | What for? |
| ------ | :------: | ------ | ------ |
| `image_before` | _String_ | `output_file + '_before.png'` | |
| `image_after` | _String_ | `output_file + '_after.png'` | |
| `image_comparison` | _String_ | `output_file + '_comparison.png'` | |
| `width` | _Number_ | 400 | |
| `height` | _Number_ | 225 | |
| `before_color` | _String_ | white | 'before' waveform color |
| `after_color` | _String_ | #ff00b3 | 'after' waveform color |
### options.silent
**Type**: _Boolean_
**Default**: `true`
Enables logging `stdout` / `stderr` data
### @output
**Type**: _Object_
```javascript
{
"file": "z:\test_normalized.mp4",
"waveform": "z:\test.mp4_comparison.png"
}
```
## Usage
```javascript
const NormalizeVolume = require('normalize-volume');
let options = {
normalize: true,
waveform: { width: 1400, height: 225 },
ffmpeg_bin: 'ffmpeg.exe',
convert_bin: 'convert.exe'
}
NormalizeVolume('z:\test.mp4', 'z:\test_normalized.mp4', options)
.then(result => {
console.log(result);
})
.catch(err => {
console.log(err);
})
```
## Changelog
#### 1.0.8:
- Now the Promise returns an error object `{ code, []errors }` (in case an error occurred).