[flac-dev] FLAC QUESTION
Brian Willoughby
brianw at sounds.wa.com
Fri Apr 13 07:53:46 PDT 2012
On Apr 12, 2012, at 07:12, Rafael Velasquez wrote:
> I'm using flac for an application.
> The fact is that i'm trying to encode a file that is not necessary
> a wav file.
>
> So, at first, i would like to know if it's possible to encode a
> file different from the wav file with the flac encoder ?
First of all, the FLAC API does not work with WAV format data - you
must provide raw audio samples. If you have a WAV file, then you
should use other code (your own?) to extract the raw audio samples
from the file, leaving out the chunk headers and other, non-audio
information. You should also make sure that the FLAC object is
initialized to accept the same size samples and channel count as you
have in your data, and it would probably be a good idea to match the
sample rate as well for proper decoding later. Beware that the
format you have may not exactly match what the FLAC library wants, so
you may have to alter the data slightly before sending it to the API.
So, it doesn't matter whether you have WAV, AIFF, SDII, or some other
file, because your code must first extract the raw audio samples from
the file before calling the FLAC library.
Note that you can encode a WAV file as FLAC, and then later decode
the FLAC file as AIFF. FLAC does not usually care what the
uncompressed foreign file format was (unless you use "preserve
foreign metadata"). These operations are supported by the command-
line program, but the WAV and AIFF format code is not part of the
FLAC library.
> When i put my data into : ok =
> FLAC__stream_encoder_process_interleaved(encoder, pcm, need);
>
> after some rounds in my boucl i get :
> encoding: FAILED
> state: FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA
> (<=== what does it really mean ? and what are the reasons to be in
> this case ? )
>
> I'm not english spoker, so sorry if i'm not very clear.
There is documentation for the FLAC API. I do not see anything
describing error messages, but you could look into the source code.
My guess is that "mismatch" refers to the checksum. I do not have an
answer for you here, but perhaps you can continue to work on your
code and find the problem.
Brian Willoughby
Sound Consulting
More information about the flac-dev
mailing list