Skip to main content

Topic: libfaac encoding problem (Read 2753 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • hub2
  • [*]
libfaac encoding problem
I'm making a C++ program that recordes audio from microphone and encodes it to MPEG4 MAIN AAC file . I made a function for encoding to AAC using libfaac and i got weird output file.I don't know what i'm doing wrong .Could you tell me what's wrong in my function.This is my RAW PCM 16-bit file File and this is output file File
Here's my code.
Code: [Select]
static void encodeAac( const char *infilename,const char *filename)
    faacEncHandle codec;
    faacEncConfigurationPtr conf;
    SAMPLE* samples;
    uint8_t*    outbuf;
    unsigned long* one;
    unsigned long* two;
    int outsize;

    one=new unsigned long;
    two = new unsigned long;
        error("Something went wrong");
    FILE *f = fopen(filename, "wb");
    FILE *fin=fopen(infilename,"rb");
    if (!fin) {
        error("could not open temporary file");
    if (!f) {
        error("could not open output file");
    samples = new SAMPLE[*one];
    outbuf = new uint8_t[*two];
    while(outsize != 0){
    delete outbuf;
    delete samples;


  • nu774
  • [*][*][*][*][*]
  • Developer
libfaac encoding problem
Reply #1
If your input is 16bit PCM and type of SAMPLE is int16_t or short, probably you need
Code: [Select]
conf->inputFormat = FAAC_INPUT_16BIT;

before passing conf to faacEncSetConfiguration().
Why don't you read faac and frontend source?

  • hub2
  • [*]
libfaac encoding problem
Reply #2
Thanks nu774 that helped. I read pdf that was with libfaac and there in faacEncConfiguration reference wasn't anything about inputFormat . Thanks i'll read source code before asking again.