summaryrefslogtreecommitdiff
path: root/opt/noNoise-master/noNoise.sh
blob: f247568d4f7b29bdff518f2e1c4dcf03960cc5af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

# Please install 'libav-tools' for Ubuntu 14.04 onwards
# As ffmpeg is obsolete, it has been replaced by 'avconv'
# Instead of python script, a simple bash one is sufficient

# A beta release for noNoise-v2

# Usage example
# $ bash noNoise.sh noisyVideo.mp4 noise-reduction-factor
							
# noise-reduction-factor: 0 means no reduction, 1 means 
# maximum damping of noise (recommended is 0.2 to 0.4)



# Making a backup of the original video
echo "Back up original video at  /tmp/orig_$1"
cp -v $1 /tmp/orig_$1

# Extracting audio from noisyVideo
avconv -i $1 -f wav -ab 192000 -vn /tmp/noisy.wav

# Creating a noise profile, basically looking for white noise
# in 0 to 0.5 sec of the clip (change if you like)
sox /tmp/noisy.wav -n trim 0 0.5  noiseprof myprofile

# Removing noise using noise profile
sox /tmp/noisy.wav /tmp/noisefree.wav noisered myprofile $2

# Replacing noisyAudio with noisefree audio in original video
avconv -i $1 -i /tmp/noisefree.wav -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 noisefree_$1.mp4