Menu

Converting u-law wav to flac

Help
nussy
2013-08-30
2013-08-30
  • nussy

    nussy - 2013-08-30

    Hi,
    first of all thank you for your work!
    The converter works just fine out of the box for many of my purposes.

    But now I'm running in some kind of issue (I'm using the latest 0.3.1 version):
    Some background: With JMF I recorded a rtp-stream (u-law). If I play the recorded .wav file it shows me the following Codec Information:

    Codec: PCM MU-LAW (mlaw)
    Channels: Mono
    Sample rate: 8000 Hz
    Bits per sample: 8
    

    Now I try to convert this file to a flac with the following code (wich works fine for other .wav-files):

    FLAC_FileEncoder flacEncoder = new FLAC_FileEncoder();
    File inputFile = new File("record.wav");
    File outputFile = new File("record.flac");
    flacEncoder.encode(inputFile, outputFile);
    

    That runs without Exception (just some "Running verbatim" prints on the error stream).

    If I want to play the resulting .flac-file the vlc-player just crashes.

    I played around with the StreamConfiguration by setting bitsPerSample, sampleRate and channelCount but without success.

    Is this really an 8000 Hz/ 8bit / u-law issue or do I just something terribly wrong?

    FYI: an input-wav file with the following Codec works just fine with the code above:

    Codec: PCM S16 LE (araw)
    Channels: Mono
    Sample rate: 8000 Hz
    Bits per sample: 16
    

    If it will help i can upload an example soundfile wich doesen't work for me.

    Thanks in advice.

     
  • Preston Lacey

    Preston Lacey - 2013-08-30

    Greetings,
    u-law won't work with FLAC to my knowledge, since it is a non-linear format. While technically you can encode it losslessly(though compression wouldn't be great), the problem would come during playback where a decoder is interpreting it as linear PCM. Why this crashed vlc though, I can't say(I would have expected it to play distorted audio). The fact that the encoder accepted u-law as input is a bug, so thanks for posting this; I will fix that as well as the extraneous error stream output in a future release. To encode your files, you will need to first convert them to 16 bit linear pcm. After encoding to FLAC you may not see much improvement in size(if any) over the original u-law file, due to the bitrate/quality tradeoffs in the two encoding schemes.

    Hope this helps, and good luck with your project

     
  • nussy

    nussy - 2013-08-30

    Thanks for your quick response!

    I'll try to convert it in the 16bit linear format before converting it to FLAC.

    In this case I'm not using FLAC due improvement-reasons or something like this. I'm using it because of the inofficial Google voice recognition api that only supports flac as input type ;-)

    *edit:
    By converting it temporarily in another format as you suggested it worked for me!
    Thank you for your assistance.

     

    Last edit: nussy 2013-08-31

Log in to post a comment.