How do you adjust the size of Input and Output Buffers used by Android MediaCodec?
up vote
0
down vote
favorite
I am trying to process audio signal data while streaming at the same time, using Android AudioTrack/MediaCodec APIs.
The audio data must be cut into frames(windows) of certain sizes (1024 in my case) before I do any further analysis, which is why I was trying to change the size of input and output buffers going into the MediaCodec so that they are of the same size as, or multiples of the frame sizes.
readBuffer = ByteBuffer.allocate(2048);
writeBuffer = ByteBuffer.allocate(2048);
Code above allocates byte buffers of capacity 2048 to readBuffer and writeBuffer, as I verified by logging readBuffer.capacity().
However, these two lines of code seem to dequeue an input buffer with a much larger capacity (readBuffer.capacity(): 196608):
inputBufIndex = codec.dequeueInputBuffer(1000);
readBuffer = codec.getInputBuffer(inputBufIndex);
I have three questions:
How is the size of the result buffer of codec.getInputBuffer() determined? Does it depend on the media format used?
As described above, is it correct to match the buffer size with the frame size if I want to stream and analyze the audio data simultaneously?
How would you resize the input and output buffers that go through the MediaCodec?
java
add a comment |
up vote
0
down vote
favorite
I am trying to process audio signal data while streaming at the same time, using Android AudioTrack/MediaCodec APIs.
The audio data must be cut into frames(windows) of certain sizes (1024 in my case) before I do any further analysis, which is why I was trying to change the size of input and output buffers going into the MediaCodec so that they are of the same size as, or multiples of the frame sizes.
readBuffer = ByteBuffer.allocate(2048);
writeBuffer = ByteBuffer.allocate(2048);
Code above allocates byte buffers of capacity 2048 to readBuffer and writeBuffer, as I verified by logging readBuffer.capacity().
However, these two lines of code seem to dequeue an input buffer with a much larger capacity (readBuffer.capacity(): 196608):
inputBufIndex = codec.dequeueInputBuffer(1000);
readBuffer = codec.getInputBuffer(inputBufIndex);
I have three questions:
How is the size of the result buffer of codec.getInputBuffer() determined? Does it depend on the media format used?
As described above, is it correct to match the buffer size with the frame size if I want to stream and analyze the audio data simultaneously?
How would you resize the input and output buffers that go through the MediaCodec?
java
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to process audio signal data while streaming at the same time, using Android AudioTrack/MediaCodec APIs.
The audio data must be cut into frames(windows) of certain sizes (1024 in my case) before I do any further analysis, which is why I was trying to change the size of input and output buffers going into the MediaCodec so that they are of the same size as, or multiples of the frame sizes.
readBuffer = ByteBuffer.allocate(2048);
writeBuffer = ByteBuffer.allocate(2048);
Code above allocates byte buffers of capacity 2048 to readBuffer and writeBuffer, as I verified by logging readBuffer.capacity().
However, these two lines of code seem to dequeue an input buffer with a much larger capacity (readBuffer.capacity(): 196608):
inputBufIndex = codec.dequeueInputBuffer(1000);
readBuffer = codec.getInputBuffer(inputBufIndex);
I have three questions:
How is the size of the result buffer of codec.getInputBuffer() determined? Does it depend on the media format used?
As described above, is it correct to match the buffer size with the frame size if I want to stream and analyze the audio data simultaneously?
How would you resize the input and output buffers that go through the MediaCodec?
java
I am trying to process audio signal data while streaming at the same time, using Android AudioTrack/MediaCodec APIs.
The audio data must be cut into frames(windows) of certain sizes (1024 in my case) before I do any further analysis, which is why I was trying to change the size of input and output buffers going into the MediaCodec so that they are of the same size as, or multiples of the frame sizes.
readBuffer = ByteBuffer.allocate(2048);
writeBuffer = ByteBuffer.allocate(2048);
Code above allocates byte buffers of capacity 2048 to readBuffer and writeBuffer, as I verified by logging readBuffer.capacity().
However, these two lines of code seem to dequeue an input buffer with a much larger capacity (readBuffer.capacity(): 196608):
inputBufIndex = codec.dequeueInputBuffer(1000);
readBuffer = codec.getInputBuffer(inputBufIndex);
I have three questions:
How is the size of the result buffer of codec.getInputBuffer() determined? Does it depend on the media format used?
As described above, is it correct to match the buffer size with the frame size if I want to stream and analyze the audio data simultaneously?
How would you resize the input and output buffers that go through the MediaCodec?
java
java
edited yesterday
asked Nov 7 at 7:39
user3052069
6719
6719
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185230%2fhow-do-you-adjust-the-size-of-input-and-output-buffers-used-by-android-mediacode%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password