Last active
July 27, 2018 13:32
-
-
Save tuck1s/4e50ed6937f3521ecf5c54fa748c54c1 to your computer and use it in GitHub Desktop.
Take mono sound from captured video(s), clean and normalise it, merge back in as centred stereo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# put output files in subdir "done" | |
mkdir -p done | |
for i in *.mp4 | |
do | |
# Extract mono (left) channel from captured video into a .wav file | |
ffmpeg -i "$i" -vn -ac 1 aud1.wav | |
# Learn noise profile from first x seconds of file, which should be "silence" | |
sox aud1.wav -n trim 0 1.0 noiseprof speech.noise | |
# Noise reduction, with mild strength, normalise file volume to -3dB, mix as identical (centre) L R stereo | |
sox aud1.wav aud2.wav noisered speech.noise 0.1 gain -b -n -3 remix 1 1 | |
# Merge video and audio back together, keeping video identical | |
ffmpeg -i "$i" -i aud2.wav -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 "done/$i" | |
# tidy up | |
rm aud1.wav aud2.wav speech.noise | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment