faac 라이브러리, pcm 변환aac 파일 예시

3322 단어 비디오
wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
tar zxvf faac-1.28.tar.gz
cd faac-1.28
./configure
make
sudo make install
 

mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’
 
#ifdef __cplusplus
extern "C" {
#endif
char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif

수정 후
#ifdef __cplusplus
extern "C++" {
#endif
const char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
ln -s  /usr/local/lib/libfaac.so.0  /usr/lib/libfaac.so   #//ubuntu , 

ldconfig    // 
#include 
#include 
 
typedef unsigned long   ULONG;
typedef unsigned int    UINT;
typedef unsigned char   BYTE;
typedef char            _TCHAR;
 
int main(int argc, _TCHAR* argv[])
{
    ULONG nSampleRate = 11025;  //  
    UINT nChannels = 1;         //  
    UINT nPCMBitSize = 16;      //  
    ULONG nInputSamples = 0;
    ULONG nMaxOutputBytes = 0;
 
    int nRet;
    faacEncHandle hEncoder;
    faacEncConfigurationPtr pConfiguration; 
 
    int nBytesRead;
    int nPCMBufferSize;
    BYTE* pbPCMBuffer;
    BYTE* pbAACBuffer;
 
    FILE* fpIn; // PCM file for input
    FILE* fpOut; // AAC file for output
 
    fpIn = fopen("in.pcm", "rb");
    fpOut = fopen("out.aac", "wb");
 
    // (1) Open FAAC engine
    hEncoder = faacEncOpen(nSampleRate, nChannels, &nInputSamples, &nMaxOutputBytes);
    if(hEncoder == NULL)
    {
        printf("[ERROR] Failed to call faacEncOpen()
"); return -1; } nPCMBufferSize = nInputSamples * nPCMBitSize / 8; pbPCMBuffer = new BYTE [nPCMBufferSize]; pbAACBuffer = new BYTE [nMaxOutputBytes]; // (2.1) Get current encoding configuration pConfiguration = faacEncGetCurrentConfiguration(hEncoder); pConfiguration->inputFormat = FAAC_INPUT_16BIT; // (2.2) Set encoding configuration nRet = faacEncSetConfiguration(hEncoder, pConfiguration); for(int i = 0; 1; i++) { // , nPCMBufferSize, nBytesRead = fread(pbPCMBuffer, 1, nPCMBufferSize, fpIn); // , , nPCMBufferSize/(nPCMBitSize/8); nInputSamples = nBytesRead / (nPCMBitSize / 8); // (3) Encode nRet = faacEncEncode( hEncoder, (int*) pbPCMBuffer, nInputSamples, pbAACBuffer, nMaxOutputBytes); fwrite(pbAACBuffer, 1, nRet, fpOut); printf("%d: faacEncEncode returns %d
", i, nRet); if(nBytesRead <= 0) { break; } } /* while(1) { // (3) Flushing nRet = faacEncEncode( hEncoder, (int*) pbPCMBuffer, 0, pbAACBuffer, nMaxOutputBytes); if(nRet <= 0) { break; } } */ // (4) Close FAAC engine nRet = faacEncClose(hEncoder); delete[] pbPCMBuffer; delete[] pbAACBuffer; fclose(fpIn); fclose(fpOut); //getchar(); return 0; }

 
g++ pcm2aac.cpp -o pcm2aac -L/usr/local/lib -lfaac -I/usr/local/include
./pcm2aac

좋은 웹페이지 즐겨찾기