IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
SoX crashes when reading FLAC files (on Windows)
Ben Johnson
post Sep 8 2008, 05:48
Post #1





Group: Members
Posts: 6
Joined: 30-July 08
Member No.: 56479



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!
Go to the top of the page
+Quote Post
Ben Johnson
post Sep 17 2008, 04:06
Post #2





Group: Members
Posts: 6
Joined: 30-July 08
Member No.: 56479



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 smile.gif.
Go to the top of the page
+Quote Post
jcoalson
post Sep 17 2008, 06:00
Post #3


FLAC Developer


Group: Developer
Posts: 1526
Joined: 27-February 02
Member No.: 1408



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.
Go to the top of the page
+Quote Post
Azevedo
post Mar 24 2013, 18:56
Post #4





Group: Members
Posts: 100
Joined: 3-November 08
Member No.: 61632



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!

This post has been edited by Azevedo: Mar 24 2013, 18:57
Go to the top of the page
+Quote Post
chi
post Mar 24 2013, 19:40
Post #5





Group: Members
Posts: 45
Joined: 27-November 11
Member No.: 95439



QUOTE (Azevedo @ Mar 24 2013, 18:56) *
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. smile.gif

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).
Go to the top of the page
+Quote Post
Azevedo
post Mar 24 2013, 20:23
Post #6





Group: Members
Posts: 100
Joined: 3-November 08
Member No.: 61632



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

Now only .m4a support is missing! sad.gif

Thanks!
Go to the top of the page
+Quote Post
romor
post Mar 24 2013, 22:24
Post #7





Group: Members
Posts: 682
Joined: 16-January 09
Member No.: 65630



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

CODE
neroaacdec -if input.m4a -of - | sox - ...


or use faad decoder


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
Azevedo
post Mar 24 2013, 23:43
Post #8





Group: Members
Posts: 100
Joined: 3-November 08
Member No.: 61632



QUOTE (romor @ Mar 24 2013, 18:24) *
You can always pipe the data to sox. For example, for m4a you can use nero decoder:

CODE
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



This post has been edited by Azevedo: Mar 24 2013, 23:45
Go to the top of the page
+Quote Post
romor
post Mar 25 2013, 00:04
Post #9





Group: Members
Posts: 682
Joined: 16-January 09
Member No.: 65630



Try this:
CODE
neroAacDec.exe -if input.m4a -of - | sox.exe -t raw -e signed -b 16 -c 2 -r 44k - -n spectrogram


This post has been edited by romor: Mar 25 2013, 00:04


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
Azevedo
post Mar 25 2013, 00:51
Post #10





Group: Members
Posts: 100
Joined: 3-November 08
Member No.: 61632



QUOTE (romor @ Mar 24 2013, 20:04) *
Try this:
CODE
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:
Go to the top of the page
+Quote Post
romor
post Mar 25 2013, 00:58
Post #11





Group: Members
Posts: 682
Joined: 16-January 09
Member No.: 65630



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"

This post has been edited by romor: Mar 25 2013, 00:59


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
Azevedo
post Mar 25 2013, 01:32
Post #12





Group: Members
Posts: 100
Joined: 3-November 08
Member No.: 61632



QUOTE (romor @ Mar 24 2013, 20:58) *
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!
Go to the top of the page
+Quote Post
romor
post Mar 25 2013, 13:23
Post #13





Group: Members
Posts: 682
Joined: 16-January 09
Member No.: 65630



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
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


--------------------
scripts: http://goo.gl/M1qVLQ
Go to the top of the page
+Quote Post
chi
post Mar 26 2013, 13:10
Post #14





Group: Members
Posts: 45
Joined: 27-November 11
Member No.: 95439



QUOTE (romor @ Mar 25 2013, 13:23) *
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
sox.exe --i -D
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 26th November 2014 - 14:23