summaryrefslogtreecommitdiff
path: root/opt/noNoise-master/README.rst
blob: 0efdbd41d7d253086b01c8c465225037933984aa (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
Introduction
============

With home made videos or screencasts, we often find a constant noise in our recording due to electric wiring, fan, choke coil of fluorescent
lamp etc. This could be  irritating.But fortunately, these noises can be easily detected and can be removed with GUI based tools, such as 
Audacity.
To use any GUI based tool, we need to extract audio manually and then feed it to the software, once done we have to again join the noisefree
audio with the video. This is OK with 1 or 2 files. But to for automating each step and to handle multiple files we need a simple script.

One can simply use `sox` and `ffmpeg` commands shown below in given order to get the same result(see `Working`).


UPDATE for 14.04
----------------

Install **libav-tools** and **sox**.

Run as ::

	$ bash noNoise.sh noisyVideo.mp4 noise-reduction-factor

This will create an backup file of original video in **/tmp**
and noisefreeVideo in **pwd**.

Example ::

	$ bash noNoise.sh Kazam_screencast_00000.mp4 0.2

It will create **noisefree_Kazam_screencast_00000.mp4.mp4** in **pwd**
and a backup of original video in **/tmp/orig_Kazam_screencast_00000.mp4**

This is just an early fix, will add more features soon. 

Please raise issues for any bugs or email me for feature requests. 

Also, I recently came across **Kazam** package (available in repositories),
its a good screen recorder with most needed keyboard shortcuts, such as

* start recording: Super + Control + r
* pause recording: Super + Control + p
* finish recording: Super + Control + f
* show Kazam: Super + Control + s
* quit: Super + Control + q

Required packages (Upto Ubuntu 13.10)
-------------------------------------

 *  sox

 * ffmpeg

 * ffmpeg2theora

 * libmp3lame0

 * Linux machine with default python 



Usage
-----

### Remove noise from a single file

    
      $ python noNoise.py VideoWithNoise.ogv  CleanVideo.ogv
                            (source file)     (destination file)
                    
(OR)

      $ python noNoise.py VideoWithNoise.ogv  CleanVideo.ogv     0.21
                            (source file)     (destination file) (noise factor)  

   The third argument is optional(Noise factor). The scale spans from 
   `0.0` to `1.0`. Zero means no noise supression and 1.0 means full. The full
   scale is avoided. Best optimum result is found between `0.2` to `0.3`. By default
   script will take `0.26`. One can experiment with noise factor to get best noise
   free video. 
   NOTE: Careful, destination file will be overwritten if exist in given path.
   


### Remove noise from all files inside a directory

      
      $ python noNoise.py allNoisyFiles  allCleanFiles
                            (source dir)  (destination dir)

(OR)
                        
      $ python noNoise.py allNoisyFiles  allCleanFiles      0.21
                          (source Dir)   (destination dir) (Noise factor)

NOTE: Please don't use any '/' after directory name. It will spit error.
The fix is possible, but I don't want to spend time on it. This script is dirty
but useful(atleast for me). When I find time, I will surely modify it. Meanwhile
you all are welcome to add modifications.



Working:
-------
###1. Extracting video in less compressed format

        ffmpeg -i 1.ogv -sameq -an 2.wmv 
   
   Extracting video in wmv format for easy editing(less compressed
   than mp4,ogv,avi). We can leave the video intact and combine the
   noiseless audio later to it, but it will hamper the video quality
   of the newly joined video.
   The size of this 'wmv' will be approximately 5 times than that of
   original 'ogv' video.
   

###2. Extracting audio in less compressed format
   
        ffmpeg -i 1.ogv -sameq 2.wav
   
   Extracting audio in wav format for fast & easy editing.The size of the
   `wav` audio file will be approximately 8 times larger than the original.


###3. Getting noise profile
        
        sox 2.wav -t null /dev/null trim 0 0.5 noiseprof myprofile
   
   Creating a noise profile of original audio at 0 to 0.5 second.
   One can change this duration if required. In most cases the
   standard noise is evenly distributed throughout the recording(eg: 
   fan, PC etc), so the default 0 to 0.5 value will do the trick.

###4. Converting audio according to noise profile
    
       sox 2.wav 2-noisefree.wav noisered myprofile 0.26

   Creating a noisefree audio based on our noise profile. The value 
   `0.26` is important. This is scale for noise removal. 0 means no removal
   and 1 means full removal. The full removal will supress most of the
   orginal audio too. So as per my R&D, I found `0.26` to be most optimized
   one for noise removal.

   
###5. Combining back audio and video
   
       ffmpeg -i 2-noisefree.wav -i 2.wmv -sameq vid.wmv

   Merging new noiseless audio and old video together.


###6. Final conversion
       
       ffmpeg2theora vid.wmv -o vid.ogv

   Now converting wmv into our favorite ogv format. This will create a 
   `vid.ogv` of almost same size that of original video.


License
-------
GNU GPLV3