Skip to content

Instantly share code, notes, and snippets.

@xenotropic
Created April 14, 2021 19:11
Show Gist options
  • Save xenotropic/c4802fad7e2e5496aecc835743804101 to your computer and use it in GitHub Desktop.
Save xenotropic/c4802fad7e2e5496aecc835743804101 to your computer and use it in GitHub Desktop.
ffmpeg compand Dynamic Range Compression
#!/bin/bash
# Dynamic range compression via ffmpeg. Takes single filename as input, writes temporarily to a file in tempdir, then copies back (and overwrites!) to the original location.
# Because of the overwrite, make sure you're working with a backed-up file, at least at first.
# Based on https://medium.com/@jud.dagnall/dynamic-range-compression-for-audio-with-ffmpeg-and-compand-621fe2b1a892
tempdir=/home/joe/temp/ #modify to be a place writable by the script
extension="${1##*.}"
ffmpeg -y -err_detect ignore_err -copyts -i "$1" -filter_complex "compand=attacks=0:points=-80/-900|-45/-15|-27/-9|0/-7|20/-7:gain=5" "${tempdir}ffcompand-temp.${extension}" && mv "${tempdir}ffcompand-temp.${ex\
tension}" "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment