Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: SoX crashes when reading FLAC files (on Windows) (Read 9234 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

SoX crashes when reading FLAC files (on Windows)

Hello, everyone,

I have managed to compile SoX on Windows (Vista 32-bit) with support for LAME MP3, MAD MP3, FLAC, and OggVorbis. Everything works fine -- except for reading FLAC audio files.

I can write FLAC files just fine, but for whatever reason, reading FLAC files causes an Application Error: "The instruction at 0x76e83387 referenced memory at 0x00000014. The memory could not be written." I am accessing sox.exe on the Windows command prompt.

I compiled SoX using flac-1.2.1-devel-win with libFLAC.lib, which, of course, requires libFLAC.dll to be accessible when sox.exe is executed. I've tried compiling with older versions of FLAC and the result is the same.

Has anyone run into this type of thing before? Any insight would be much appreciated.

Thanks!

SoX crashes when reading FLAC files (on Windows)

Reply #1
I solved this problem by compiling libFLAC.dll (by default, named libFLAC_dynamic.dll) from source. Originally, I had used the libFLAC.dll provided with the flac-1.2.1-devel-win package, because I was having trouble compiling (see next paragraph). I'm not entirely sure what the difference between the two files might be.

For anyone else who attempts to compile FLAC from source and runs into the error, "A tool returned an error code from 'Performing Custom Build Step'", have a look at the Output tab in Visual Studio. There is reference to nasmw.exe (the Nasm compiler), and in my case, it was necessary for me to download nasmw.exe (I obtained the file from http://code.google.com/p/ambraos/downloads...mp;can=2&q= ) and copy the file to the C:\Windows\System32 directory before attempting the build.

I ran into another error when compiling FLAC, given that "ogg_static.lib" was missing from the flac-1.2.1\obj\release directory. It was necessary to download the libogg source and compile to obtain ogg_static.lib. Once I had placed ogg_static.lib in the referenced directory, the build succeeded without issue, to yield the DLL that ultimately solved the crashing problem.

I intend to write an end-to-end tutorial for compiling SoX with FLAC, MP3, and OGG/vorbis support on Windows when time permits. Naturally, I'll be further compelled if others express an interest in the information .

SoX crashes when reading FLAC files (on Windows)

Reply #2
that stuff is in the README.win32 in the source zip, and also info on how to build without nasm or ogg support.

not sure why the library was crashy with sox though.

SoX crashes when reading FLAC files (on Windows)

Reply #3
Hey Ben, would you share your build with flac/ogg/mp3 support please?
I cant find any flaclib.dll that will work with sox.

Thanks!

SoX crashes when reading FLAC files (on Windows)

Reply #4
Hey Ben, would you share your build with flac/ogg/mp3 support please?


It might be slightly outdated. Have a look at when the previous posts were written.

You should be able to get a working (and recent) version here: http://sourceforge.net/projects/sox/files/sox/14.4.1/
Take one of the files with “a” in the version number (sox-14.4.1a-win32.zip, sox-14.4.1a-win32.exe), they will support FLAC and Ogg Vorbis. Probably also MP3 if you have the required DLLs. Unfortunately, sndfile and the formats provided by it are still not working (see here).

SoX crashes when reading FLAC files (on Windows)

Reply #5
hmm.. thanks for that!
it goes with .flac .mp3 (with dll)

Now only .m4a support is missing!

Thanks!

SoX crashes when reading FLAC files (on Windows)

Reply #6
You can always pipe the data to sox. For example, for m4a you can use nero decoder:

Code: [Select]
neroaacdec -if input.m4a -of - | sox - ...


or use faad decoder

SoX crashes when reading FLAC files (on Windows)

Reply #7
You can always pipe the data to sox. For example, for m4a you can use nero decoder:

Code: [Select]
neroaacdec -if input.m4a -of - | sox - ...


or use faad decoder



Cool! thanks! nice tip!
I may be missing something...

neroAacDec.exe -if input.m4a -of - | sox.exe -n spectrogram -o spectrogram.png
sox.exe FAIL sox: Not enough input filenames specified



neroAacDec.exe -if input.m4a -of - | sox.exe - -n spectrogram -o spectrogram.png
sox.exe WARN wav: Premature EOF on .wav input file


 

SoX crashes when reading FLAC files (on Windows)

Reply #8
Try this:
Code: [Select]
neroAacDec.exe -if input.m4a -of - | sox.exe -t raw -e signed -b 16 -c 2 -r 44k - -n spectrogram

SoX crashes when reading FLAC files (on Windows)

Reply #9
Try this:
Code: [Select]
neroAacDec.exe -if input.m4a -of - | sox.exe -t raw -e signed -b 16 -c 2 -r 44k - -n spectrogram

hmmm works better but not the same result:

Original:


Using the pipe:

SoX crashes when reading FLAC files (on Windows)

Reply #10
AFAIK when piping sox needs to know the length of data to draw spectrogram or defaults to 8 seconds. You can specify the length on command line (check the manual) or use temp file instead piping.

BTW, I made a typo "-r 44k" should actually be "-r 44.1k"

SoX crashes when reading FLAC files (on Windows)

Reply #11
AFAIK when piping sox needs to know the length of data to draw spectrogram or defaults to 8 seconds. You can specify the length on command line (check the manual) or use temp file instead piping.

BTW, I made a typo "-r 44k" should actually be "-r 44.1k"


That's ok. i think the problem is with the windows command line pipe code. It look like it has a limit on the pipe size.
I'll stick with the old script for m4a:

ffmpeg: mp4a -> wav
sox: wav -> process
del temp wav

As for mp3 and flac, Sox now reads these formats.

Thanks everyone!

SoX crashes when reading FLAC files (on Windows)

Reply #12
Azevedo, if you know the track length you just append the value on -d switch. For example, according your first image your test track seems to be around 3:32, in which case you could have used:

Code: [Select]
neroAacDec.exe -if input.m4a -of - | sox.exe -t raw -e signed -b 16 -c 2 -r 44k - -n spectrogram -d 3:32

and get the same image.

If you don't know the length, then you could perhaps use some tool that can print this value and you can catch it with "for" command tokens to a variable which you can then append to arguments as shown above. That would be definitely better then using temp file

SoX crashes when reading FLAC files (on Windows)

Reply #13
If you don't know the length, then you could perhaps use some tool that can print this value


SoX (SoXi) can do this:
Code: [Select]
sox.exe --i -D