1
votes

I'm using libFlac to convert a mono wave file to flac.

I'm using a sample file from the wav section in wikipedia, that can be downloaded here

The example code that comes with libFlac says in the documentation that it only supports 16-bit stereo files.

According to libFlac documentation, the library supports 1-8 channels, so there shouldn't be any problem.

I tried changing the example code to simply allow encoding a mono file by simply replacing the lines

//channels = 2;
channels = 1;

The rest of the code looks like it should support one channel without any problems, but when I try to encode a mono file I get a corrupted audio. (The original audio but with "holes" in the audio).

Does any one have a libFlac example that supports encoding a mono file?

1

1 Answers

0
votes

In the end, the problem was the sample rate. The mono wav file I was using had sample rate of 8000, and when I encoded it to a flac with a sample rate of 8000 the audio is corrupted, even when using utilities like sox

When I encoded the wav into a flac file with a sample rate of 16000, the file was encoded correctly.

I'll post an issue to libFlack about this matter.