Play audio using FFMPEG

I am trying to transfer FFMPEG (for playing audio) to Android using NDK. I had some success

  • I could build FFMPEG and link it through the NDK.
  • I could call avcodec_decode_audio3()and decode this audio file.

So, here I have a sound buffer output from a function. How do i play now? Any guys from ffmpeg can tell me the exact steps for decoding and playing audio. I really don't know what to do with the sound buffers I created from avcodec_decode_audio3().

Many thanks.

+3
source share
1 answer

android ffmpeg. AudioTrack .

:

Java audiotrack

AudioTrack track;
bufferSize = AudioTrack.getMinBufferSize(44100,AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT)
track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize, mode);

//Play audio clip
track.play();

while(stream_is_over){
//Copy the decoded raw buffer from native code to "buffer" .....
............
track.write(buffer, 0, readBytes);
}
+2

Source: https://habr.com/ru/post/1792149/


All Articles