yonilevy / noiseclean

A simple bash script to remove audio noise from audio and videos files.
111 stars 17 forks source link

sox FAIL formats: can't open input file `/tmp/noiseclean_tmpaud.wav': No such file or directory #3

Closed qadirsuh closed 3 years ago

qadirsuh commented 7 years ago

Thanks for your reply on issue #2

I installed the below

$ brew install ffmpeg
$ brew install sox

I tried again. see the log below

qadir-mac:noiseclean qadirhussain$ sh noiseclean.sh babble.wav babble-test.wav 
Detected 'babble.wav' as an audio file
Sample noise start time [00:00:00]: 
Sample noise end time [00:00:00.500]: 
Noise reduction amount [0.21]: 
Cleaning noise on 'babble.wav'...
Guessed Channel Layout for Input Stream #0.0 : mono
sox FAIL formats: can't open input file `/tmp/noiseclean_tmpaud.wav': No such file or directory
cp: /tmp/noiseclean_tmpaud-clean.wav: No such file or directory
Done

I am getting this error now sox FAIL formats: can't open input file/tmp/noiseclean_tmpaud.wav': No such file or directory` here is screenshot of my /tmp dir https://www.dropbox.com/s/g86iqx0cooojs2s/Screenshot%202017-05-03%2010.56.29.png?dl=0 Whats wrong in this now?

yonilevy commented 7 years ago

i believe you found a bug :) pull and try again, let me know if it works!

qadirsuh commented 7 years ago

Updated and now got a new error,

sox FAIL formats: can't open input file/tmp/noiseclean_tmpaud.wav': WAVE: RIFF header not found `

Here is complete log

Qadir-Hussain-mac:noiseclean qadirhussain$ sh noiseclean.sh mpthreetest.mp3 mpthreetest_clean.mp3 [mp3 @ 0x7f825f002600] Estimating duration from bitrate, this may be inaccurate Detected 'mpthreetest.mp3' as an audio file Sample noise start time [00:00:00]: Sample noise end time [00:00:00.500]: Noise reduction amount [0.21]: Cleaning noise on 'mpthreetest.mp3'... [mp3 @ 0x7f95f7800000] Estimating duration from bitrate, this may be inaccurate sox FAIL formats: can't open input file/tmp/noiseclean_tmpaud.wav': WAVE: RIFF header not found cp: /tmp/noiseclean_tmpaud-clean.wav: No such file or directory Done `

yonilevy commented 7 years ago

Could you attach the mp3 file? I'll try to make it work

qadirsuh commented 7 years ago

Does this work at your side. I have tried with wav file and mp3 files found randomly from google. Same issue appears at my side

evgenybf commented 7 years ago

It doesn't work as sox doesn't support .mp3 format 'out of box' (SoX v14.4.1 in Ubuntu 16.04) or it doesn't recognizes mp3 when it has the '.wav' extension. Instead of copying to the tmp directory, renaming mp3 to wav and back, the script could do ffmpeg conversion like this:

diff --git a/noiseclean.sh b/noiseclean.sh
index 8ff789a..18ecd46 100755
--- a/noiseclean.sh
+++ b/noiseclean.sh
@@ -63,7 +63,7 @@ if [ $isVideo -eq "1" ]; then
     ffmpeg -v warning -y -i "$1" -qscale:v 0 -vcodec copy -an "$tmpVidFile"
     ffmpeg -v warning -y -i "$1" -qscale:a 0 "$tmpAudFile"
 else
-    cp "$1" "$tmpAudFile"
+    ffmpeg -y -i "$1" "$tmpAudFile"
 fi
 ffmpeg -v warning -y -i "$1" -vn -ss "$sampleStart" -t "$sampleEnd" "$noiseAudFile"
 sox "$noiseAudFile" -n noiseprof "$noiseProfFile"
@@ -71,7 +71,8 @@ sox "$tmpAudFile" "$tmpAudCleanFile" noisered "$noiseProfFile" "$sensitivity"
 if [ $isVideo -eq "1" ]; then
     ffmpeg -v warning -y -i "$tmpAudCleanFile" -i "$tmpVidFile" -vcodec copy -qscale:v 0 -qscale:a 0 "$2"
 else
-    cp "$tmpAudCleanFile" "$2"
+    ffmpeg -y -i "$tmpAudCleanFile" "$2"
 fi

 echo "Done"
+