HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: Shane N on 2007-11-12 18:27:20

Title: SOX U-Law WAV to "Microsoft WAV"
Post by: Shane N on 2007-11-12 18:27:20
I've got U-Law WAVs that I need to encode to the Microsoft WAV format.

When I run the following command, and open the file test.wav, it works fine:
sox.exe "ulawfile.wav" -t wav -r 16000 test.wav

However, I need to run this in a PHP site, and would like it to start the download immediately so the user doesn't have to wait for it to encode, so I run this:
sox.exe "ulawfile.wav" -t wav -r 16000 -

That command is executed and the results are dumped out immediately. However, when you try to play the file, it works fine, but you cannot "jump" ahead in the file. When you click on an area in the playback bar, it gives me an error "Windows Media Player cannot play the file." If I start it from the beginning and let it play by itself, it works fine, I just can't jump around in the playback.

What would cause this?

(Sorry if this isn't the right forum, I couldn't find one that dealt with WAVs directly)
Title: SOX U-Law WAV to "Microsoft WAV"
Post by: 42ndSSD on 2007-11-12 19:53:13
sox writes .wav files with the initial length set to zero, then when the input is finished it rewrites the header with the correct value. Since you're sending the output through a pipe it can't rewrite the header; it normally gives a warning like:

Code: [Select]
sox: Length in output .wav header will be wrong since can't seek to fix it


This could cause the problems you're seeing with skipping in the file, since whatever you're using to play it doesn't know how long it is.
Title: SOX U-Law WAV to "Microsoft WAV"
Post by: Shane N on 2007-11-12 20:09:42
That is what I was afraid of. Is there any way to get around this or am I SOL?

Thanks