2016-09-12 2 views
0

xcode 버전 8.0 (8A218a)으로 iOS에서 AAC-HE-V1을 인코딩하는 데 fdk v2.0.101을 사용하지만 모노로 채널을 설정하더라도 항상 스테레오 채널 aac 데이터를 얻습니다.iOS에서 fdk로 AAC-HE-V1을 인코딩하는 중에 올바른 채널을 얻는 방법은 무엇입니까?

fdk로 AAC-HE-V1을 인코딩하는 중에 올바른 채널을 얻는 방법은 무엇입니까?

PS : AAC-LC는 정상입니다. iOS 9.3을 사용하는 iPhone 6에서 테스트되었습니다.

UINT channels = 1; 
    HANDLE_AACENCODER encoder_handle; 
    AACENC_InfoStruct encoder_info; 

    int HE_AACv1 = 5; 

    TRANSPORT_TYPE transport_type = TT_MP4_ADTS; 

    CHANNEL_MODE mode; 

    switch (channels) { 
     case 1: mode = MODE_1;  break; 
     case 2: mode = MODE_2;  break; 
     case 3: mode = MODE_1_2;  break; 
     case 4: mode = MODE_1_2_1; break; 
     case 5: mode = MODE_1_2_2; break; 
     case 6: mode = MODE_1_2_2_1; break; 
    } 

    CheckError(aacEncOpen(&encoder_handle, 0, channels), @"Unable to open encoder : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_AOT, HE_AACv1), @"Unable to set the AOT : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_SAMPLERATE, 44100), 
       @"Unable to set the sample rate : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_CHANNELMODE, mode), 
       @"Unable to set the channel mode : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_CHANNELORDER, 1), 
       @"Unable to set the wav channel order : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_BITRATE, 90000), 
       @"Unable to set the bitrate : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_TRANSMUX, transport_type), 
       @"Unable to set the ADTS transmux : %i"); 
    CheckError(aacEncoder_SetParam(encoder_handle, AACENC_AFTERBURNER, 1), 
       @"Unable to set the afterburner mode : %i"); 
    CheckError(aacEncEncode(encoder_handle, NULL, NULL, NULL, NULL), 
       @"Unable to initialize the encoder : %i"); 
    CheckError(aacEncInfo(encoder_handle, &encoder_info), @"Unable to get the encoder info : %i"); 

Enocoding 부분

초기화 부분 :

AudioBuffer originBuffer = ...; 

    AACENC_OutArgs out_args = { 0 }; 
    AACENC_ERROR err; 

    int out_identifier = OUT_BITSTREAM_DATA; 

    uint8_t *output_data = calloc(encoder_info.maxOutBufBytes, 1); 

    int read = originBuffer.mDataByteSize; 

    void *in_ptr = originBuffer.mData; 
    int in_size = read; 
    int in_elem_size = _sampleBytes; 

    int in_identifier = IN_AUDIO_DATA; 

    AACENC_InArgs in_args = { 0 }; 
    in_args.numInSamples = read/_sampleBytes; 

    AACENC_BufDesc in_buf = { 0 }, out_buf = { 0 }; 
    in_buf.numBufs = 1; 
    in_buf.bufs = &in_ptr; 
    in_buf.bufferIdentifiers = &in_identifier; 
    in_buf.bufSizes = &in_size; 
    in_buf.bufElSizes = &in_elem_size; 

    void *out_ptr; 
    int out_size, out_elem_size; 

    out_ptr = output_data; 
    out_size = _encoder_info.maxOutBufBytes; 
    out_elem_size = _sampleBytes; 
    out_buf.numBufs = 1; 
    out_buf.bufs = &out_ptr; 
    out_buf.bufferIdentifiers = &out_identifier; 
    out_buf.bufSizes = &out_size; 
    out_buf.bufElSizes = &out_elem_size; 

    AACENC_ERROR result = aacEncEncode(_encoder_handle, &in_buf, &out_buf, &in_args, &out_args); 

    if (result != AACENC_OK) { 
     free(output_data); 
     NSLog(@"FDK-AAC encode fail %i", result); 
     return; 
    } 
    if (out_args.numOutBytes > 0) { 

     // handle output_data 

    } else { 
     free(output_data); 
    } 

답변

0

나는 CHANNEL_MODE 원래 오디오 모드라고 생각

다음은 코드입니다. aac 모드가 아닙니다.

iOS는 AAC-HE-V2를 지원하지 않습니다.

fdk를 사용하여 오디오를 변환 할 필요가 없습니다.

다음은 샘플 코드입니다.

https://developer.apple.com/library/content/samplecode/iPhoneACFileConvertTest/Introduction/Intro.html

내가 너무 FDK-AAC의 IOS에 대한 몇 가지 도움이 필요합니다. 여기 링크가 있습니다. 당신이 그것을 볼 수 있기를 바랍니다. ios fdk-aac pcm to aac sample

관련 문제