I have a .wav audio file and I'm trying to create a noise profile of it using sox. However, I keep getting the following error message: sox FAIL formats: can't open input file 'Noise-Test.wav': WAV file encoding 'MP3' is not supported
It sounds to me like sox interprets the file as mp3. It should accept .wav files. Does someone know what is the issue here?
This is the code:
!sox Noise-Test.wav -n noiseprof noise.prof
Related
I've got a large (5Gb) WAV 64 file that I'm trying to analyse with SoX. On doing;
sox /file/ -n stats
it tells me;
sox FAIL formats: can't open input file '/file/': WAVE: RIFF header not found
On attempting to specify;
sox /file/ -t w64 -n stats
it says;
sox WARN sox: ignoring `-t w64'.
and proceeds to throw the same error as before. This file is W64. How do I convince SoX to accept it?
Looks like ffmpeg can handle wav64 files
Have you tried to create your own tiny wav64 file and see if you can read that ?
Looks like wav64 is targeted for multichannel audio is that your use case ? WAV format itself is very simple and lends itself to allowing people to write two pages of code to read any wav file ... if you exhaust all other options and your life depended on getting your file read, reading the ISO spec or similar on wav64 format then writing your own reader is an option.
Can you share how your wav64 file was created ? Maybe one of us can replicate its creation and battle how to read it back
If its not full of massive multi-channel audio is getting it converted to normal wav an option ?
Maybe, your wave64 file is invalid. A valid one should contain a riff header.
You've added -t w64 flag after the filename. That's why it's ignored.
# This would work! [CHECKED]
# If your file is valid!
sox -t w64 in_file -n stats
I currently have a list of file for which I need to change the sample rate for.
I'recently been aware that this is possible using sox But when I try do it, I keep on getting a error message that sox wav: Premature EOF on .wav input file And causes the audio file to be empty.. it seems like that sox is not able to resample an audio file which input = output... which I kinda need, if I have to convert a whole directory of audio files...
Currently used commands:
~/kaldi-trunk/egs/yesno/s5_k_added$ sox 0_0_0_0_1_1_1_1.wav -r 8000 0_0_0_0_1_1_1_1.wav
sox WARN wav: Premature EOF on .wav input file
:~/kaldi-trunk/egs/yesno/s5_k_added$ play 0_0_0_0_1_1_1_1.wav
0_0_0_0_1_1_1_1.wav:
File Size: 44
Encoding: Signed PCM
Channels: 1 # 16-bit
Samplerate: 8000Hz
Replaygain: off
Duration: unknown
In:0.00% 00:00:00.00 [00:00:00.00] Out:0 [ | ] Clip:0
Done.
How do I resample a directory of audio files?
Try changing the output file name, possible putting it in a different directory if you want to keep the same file name.
For example:
sox 0_0_0_0_1_1_1_1.wav -r 8000 ./out/0_0_0_0_1_1_1_1.wav
I believe sox is attempting to read the file while it is actively changing it, sometimes sox does not create a temporary file to output into.
EDIT: If you have a directory of files you all want to change, use this:
$ mkdir out
$ for file in *; do sox ${file} -r 8000 ./out/${file}; done
I am trying to convert midi files to ogg or mp3. Eventually this will happen on a linux webserver but currently I am using a Windows 7 machine. I am using timidity to convert the midi to wav and then either sox or ffmpeg to convert the wav to ogg/mp3.
When I use an intermediate file the process works fine (in the first line below timidity creates file.wav)
timidity.exe file.mid -Ow
sox.exe file.wav file.ogg
However, when I try to pipe the timidity output into sox (as below), the resulting file ogg is horribly distorted
timidity.exe file.mid -Ow -o - | sox.exe -t wav - file.ogg
and I get a warning
sox.exe WARN wav: Premature EOF on .wav input file
I also get the same distortion problem when I replace sox with ffmpeg (and the appropriate command line options), or when I replace ogg with mp3 as the output format.
So what am I doing wrong?
Thanks,
Chris
Regarding the warning itself, you're doing nothing wrong. You may also see a warning from timidity that reads something like
Warning: -: Illegal seek: Can't make valid header
What's happening there is explained in the timidity manual page:
If output is directed to a non-seekable file, or if TiMidity++ is interrupted before closing the file, the file header will contain 0xffffffff in the RIFF and data block length fields.
Note that RIFF is the encoding format commonly called by its file extension, .wav. When timidity writes a RIFF file, it doesn't know how long the file will be, so it writes some placeholder junk in the header and moves on to writing the data. When it finishes with the data, it knows how long the file is, so it goes back to the beginning of the file and writes over that junk in the header. When you write to a pipe, it has no way to go back and rewrite anything: the downstream program has to handle the placeholder junk. Also from the timidity manual page:
The popular sound conversion utility sox is able to read such malformed files, so you can pipe data directly to sox for on-the-fly conversion to other formats.
Thus, the message you mentioned. Sox is informing you that the chef prepared the file wrong BUT SOX IS HAPPY TO EAT IT ANYWAY BECAUSE SOX IS NOT PICKY. Sox is apparently passive-aggressive. Who knew?
You can ignore those warning messages, because now they are telling you something you already know. Or, you can use a raw format and explicitly tell timidity and sox how to play well with one another:
timidity file.midi -Or1Ssl -s44.1 -o- | sox -t raw -b 16 -e signed -r 44.1k -c 2 - file.ogg
As for the distortion, that may be caused in part by quirks in the audio libraries on the Windows system. I note that the pipeline in the question, sans .exe extensions, produces output with no notable distortion on a linux system. Using a well-defined raw format in the pipeline may also help with that issue.
Note that for Ogg output, you can now get that directly from timidity:
timidity file.midi -o file.ogg -Ov
In a command line, if I run:
ffmpeg -i inputVideo.mp4 -vn -f mp4 -acodec copy outputAudio.aac
everything works perfectly fine.
However if I do the same thing, except standard out instead of the output file ("pipe:1" instead of "outputAudio.aac") then I get this error:
"Could not write header for output file #0 (incorrect codec parameters ?)"
Help from anyone with ffmpeg experience is greatly appreciated
Thanks
Well the trouble is you are asking for a mp4 file with a filename of outputAudio.aac. So if you check outputAudio.aac it is actually a mp4 file. To write mp4 files ffmpeg will need a seekable file descriptor which stdout is not. [this is because mp4 moov atom is written at the end in the beginning of the file.
If you want aac to be dumped to stdout you should ask for a adts file
ffmpeg -i input.mp4 -acodec copy -vn -f adts -strict -2 -
If you need it in a mp4.. mux it after that into a file
mp4 is not a streaming format: see here Fix 3GP file after streaming from Android Media Recorder for my answer to a different question which explains this.
how do you convert a mp3wav (a compressed wav in mp3 form) to uncompressed wav (PCM) using sox?
mp3wav sample files can be downloaded here: http://www.clayloomis.com/simsong.html
I would have thought the following would simply work:
sox file.mp3 file.wav
It may be your version of sox doesn't handle MP3 files at all. I think this happened to me with the default RPM for openSUSE recently...