$ wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.1.tar.gz
1.下载源码
$ wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.1.tar.gz
2.解压
$ tar xvzf fdk-aac-2.0.1.tar.gz
3.配置
$ cd fdk-aac-2.0.1/
$ mkdir local
$ ./configure --prefix=$pwd/local --enable-example
4.编译
$ make
5.安装
$ make install
6.打自己的补丁
$ patch -p2 < ../aac-enc.path
7.重新编译并运行
$ ./fdk-aac-2.0.1/aac-enc -t 2 jzt31x_16K.pcm out.aac
--- ./fdk-aac-2.0.1/aac-enc.c 2018-10-24 15:55:23.000000000 +0800
+++ ./fdk-aac-2.0.1.bak/aac-enc.c 2020-10-28 18:01:02.605653818 +0800
@@ -29,6 +29,8 @@
#include "libAACenc/include/aacenc_lib.h"
#include "wavreader.h"
+#define AUGUSPEC
+
void usage(const char* name) {
fprintf(stderr, "%s [-r bitrate] [-t aot] [-a afterburner] [-s sbr] [-v vbr] in.wav out.aac\n", name);
fprintf(stderr, "Supported AOTs:\n");
@@ -56,6 +58,11 @@ int main(int argc, char *argv[]) {
HANDLE_AACENCODER handle;
CHANNEL_MODE mode;
AACENC_InfoStruct info = { 0 };
+#ifndef AUGUSPEC
+
+#else
+ FILE *fdPcm=NULL;
+#endif
while ((ch = getopt(argc, argv, "r:t:a:s:v:")) != -1) {
switch (ch) {
case 'r':
@@ -85,7 +92,7 @@ int main(int argc, char *argv[]) {
}
infile = argv[optind];
outfile = argv[optind + 1];
-
+#ifndef AUGUSPEC
wav = wav_read_open(infile);
if (!wav) {
fprintf(stderr, "Unable to open wav file %s\n", infile);
@@ -95,6 +102,15 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Bad wav file %s\n", infile);
return 1;
}
+#else
+ fdPcm = fopen(infile,"r");
+ printf("open file:%s\n",infile);
+ format=1;
+ channels = 1;
+ bits_per_sample = 16;
+ sample_rate = 16000;
+ info.frameLength = 1024;
+#endif
if (format != 1) {
fprintf(stderr, "Unsupported WAV format %d\n", format);
return 1;
@@ -191,7 +207,12 @@ int main(int argc, char *argv[]) {
uint8_t outbuf[20480];
AACENC_ERROR err;
+#ifndef AUGUSPEC
read = wav_read_data(wav, input_buf, input_size);
+#else
+ read = fread(input_buf,1,input_size,fdPcm);
+ printf("read %d\n",read);
+#endif
for (i = 0; i < read/2; i++) {
const uint8_t* in = &input_buf[2*i];
convert_buf[i] = in[0] | (in[1] << 8);