我使用下面的代码将声音文件转换为 ogg vorbis,但我在 libsndfile 的文档中没有找到如何设置输出文件的比特率,它始终设置为 128 kb/s。是否可以更改 libsndfile 生成的输出文件的比特率?
#include <sndfile.hh>
#define BUFFER_LEN 4096
void convert(char *infilename, char *outfilename)
{
static double data[BUFFER_LEN];
SNDFILE *infile, *outfile;
SF_INFO sfinfo;
int readcount;
infile = sf_open(infilename, SFM_READ, &sfinfo);
sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
outfile = sf_open(outfilename, SFM_WRITE, &sfinfo);
while ((readcount = sf_read_double(infile, data, BUFFER_LEN)))
{
sf_write_double(outfile, data, readcount);
}
sf_close(infile);
sf_close(outfile);
}