Android 从麦克风录制时将.pcm转换为aac

Android 从麦克风录制时将.pcm转换为aac,android,android-mediacodec,pcm,android-audiorecord,mediamuxer,Android,Android Mediacodec,Pcm,Android Audiorecord,Mediamuxer,我有一个程序,可以录制麦克风发出的声音,并将声音保存在.pcm文件中 我在程序中有一个单独的函数,它使用MediaCodec和MediaMuxer将.pcm转换为aac 是否可以修改我的程序,以便使用MediaCodec直接将.pcm转换为aac?我该怎么做?是否有指南或代码示例来实现这一点 下面是我的程序中的一段代码片段,它记录了 麦克风: recorder = new AudioRecord( MediaRecorder.AudioSource.MIC, RECORDER_

我有一个程序,可以录制麦克风发出的声音,并将声音保存在.pcm文件中

我在程序中有一个单独的函数,它使用MediaCodec和MediaMuxer将.pcm转换为aac

是否可以修改我的程序,以便使用MediaCodec直接将.pcm转换为aac?我该怎么做?是否有指南或代码示例来实现这一点

下面是我的程序中的一段代码片段,它记录了 麦克风:

recorder = new AudioRecord(
    MediaRecorder.AudioSource.MIC, 
    RECORDER_SAMPLERATE, 
    RECORDER_CHANNELS, 
    RECORDER_AUDIO_ENCODING, 
    bufferSize);

    recorder.startRecording();
    isRecording = true;

    FileOutputStream os = null;
    try {
        os = new FileOutputStream(filePathAudioRec);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    while (isRecording) {
        // gets the voice output from microphone to byte format

        recorder.read(sData, 0, BufferElements2Rec);
        try {
            // writes the data to file from buffer
            // stores the voice buffer
            byte bData[] = short2byte(sData);
            os.write(bData, 0, BufferElements2Rec * BytesPerElement); //do I need to write it to a file ??
        } catch (IOException e) {
            e.printStackTrace();
        }
// inside while loop: add code to convert to .mp4 while the data is collected from the MIC
   }

你的问题有没有得到答案?或者如果你有一个解决方案,你会在这里分享吗?谢谢你的问题有没有得到答案?或者如果你有一个解决方案,你会在这里分享吗?谢谢