Windows — использование libvo-aacenc с libav в программе на C ++

Я делаю программу, которая записывает и кодирует эту запись в aac.Я сделал функцию для Linux и libfaac, которая делает эту работу. Теперь мне нужно сделать эту программу для Windows. Я знаю, что мне нужно использовать libvo-aacenc, и я не знаю, что изменить в своем коде. Не могли бы вы сказать мне, что мне делать? Вот мой код

static void encodeAac( const char *infilename,const char *filename)
{
AVCodec *codec;
AVCodecContext *c = NULL;
int frame_size, i, j, out_size, outbuf_size;
FILE *f,*fin;
SAMPLE *samples;
float t, tincr;
uint8_t *outbuf;

avcodec_register_all();                                                 //Load all codecs
av_register_all();
codec = avcodec_find_encoder(AV_CODEC_ID_AAC);  //Search for AAC codec
if (!codec) {
error("Codec not found");
}
c = avcodec_alloc_context();
c->bit_rate = 64000;
c->sample_fmt = AV_SAMPLE_FMT_S16;
c->sample_rate = SAMPLE_RATE;
c->channels = NUM_CHANNELS;
c->time_base.num= 1;
c->time_base.den= SAMPLE_RATE;
c->profile= FF_PROFILE_AAC_MAIN;
if (avcodec_open(c, codec) < 0) {
error(add("","",avcodec_open(c, codec)).c_str());
exit(1);
}
f = fopen(filename, "wb");
fin=fopen(infilename,"rb");
if (!fin) {
error("could not open temporary file");
}
if (!f) {
error("could not open output file");
}
std::cout << c->frame_size*c->channels << std::endl;
samples = new SAMPLE[c->frame_size*c->channels];
outbuf = new uint8_t[FRAMES_PER_BUFFER * NUM_CHANNELS];
while(fread(samples,sizeof(SAMPLE),c->frame_size*c->channels,fin)){
out_size=avcodec_encode_audio(c,outbuf,FRAMES_PER_BUFFER * NUM_CHANNELS,samples);
fwrite(outbuf,sizeof(uint8_t),out_size,f);
}
for(int i=1;i<=4;i++){                          //For buffer flushing
out_size=avcodec_encode_audio(c,outbuf,FRAMES_PER_BUFFER * NUM_CHANNELS,NULL);
fwrite(outbuf,sizeof(uint8_t),out_size,f);
}

fclose(f);
delete outbuf;
delete samples;

avcodec_close(c);
av_free(c);
}

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …