libfaac encoding problem, libfaac gets me weird output |
![]() ![]() |
libfaac encoding problem, libfaac gets me weird output |
Jan 15 2013, 13:01
Post
#1
|
|
|
Group: Members Posts: 3 Joined: 7-January 13 Member No.: 105674 |
Hi,
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 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; codec=faacEncOpen(SAMPLE_RATE,NUM_CHANNELS,one,two); if(!codec){ error("Something went wrong"); return; } conf=faacEncGetCurrentConfiguration(codec); conf->mpegVersion=MPEG4; conf->aacObjectType=MAIN; faacEncSetConfiguration(codec,conf); 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(fread(samples,sizeof(SAMPLE),*one,fin)){ outsize=faacEncEncode(codec,(int*)samples,*one,outbuf,*two); fwrite(outbuf,sizeof(uint8_t),outsize,f); } while(outsize != 0){ outsize=faacEncEncode(codec,NULL,NULL,outbuf,*two); fwrite(outbuf,sizeof(uint8_t),outsize,f); } fclose(f); fclose(fin); delete outbuf; delete samples; faacEncClose(codec); } |
|
|
|
Jan 15 2013, 13:36
Post
#2
|
|
![]() Group: Developer Posts: 295 Joined: 22-November 10 From: Japan Member No.: 85902 |
If your input is 16bit PCM and type of SAMPLE is int16_t or short, probably you need
CODE conf->inputFormat = FAAC_INPUT_16BIT; before passing conf to faacEncSetConfiguration(). Why don't you read faac and frontend source? |
|
|
|
Jan 15 2013, 13:43
Post
#3
|
|
|
Group: Members Posts: 3 Joined: 7-January 13 Member No.: 105674 |
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.
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 18th May 2013 - 10:23 |