[英]getInpuBuffer in Android MediaCodec and MediaMuxer
Below is a fragment of Android MediaMuxer API sample code: https://developer.android.com/reference/android/media/MediaMuxer.html 以下是Android MediaMuxer API示例代码的片段: https : //developer.android.com/reference/android/media/MediaMuxer.html
MediaMuxer muxer = new MediaMuxer("temp.mp4", OutputFormat.MUXER_OUTPUT_MPEG_4);
// More often, the MediaFormat will be retrieved from MediaCodec.getOutputFormat()
// or MediaExtractor.getTrackFormat().
MediaFormat audioFormat = new MediaFormat(...);
MediaFormat videoFormat = new MediaFormat(...);
int audioTrackIndex = muxer.addTrack(audioFormat);
int videoTrackIndex = muxer.addTrack(videoFormat);
ByteBuffer inputBuffer = ByteBuffer.allocate(bufferSize);
boolean finished = false;
BufferInfo bufferInfo = new BufferInfo();
muxer.start();
while(!finished) {
// getInputBuffer() will fill the inputBuffer with one frame of encoded
// sample from either MediaCodec or MediaExtractor, set isAudioSample to
// true when the sample is audio data, set up all the fields of bufferInfo,
// and return true if there are no more samples.
finished = getInputBuffer(inputBuffer, isAudioSample, bufferInfo);
if (!finished) {
int currentTrackIndex = isAudioSample ? audioTrackIndex : videoTrackIndex;
muxer.writeSampleData(currentTrackIndex, inputBuffer, bufferInfo);
}
};
muxer.stop();
muxer.release();
For this line: finished = getInputBuffer(inputBuffer, isAudioSample, bufferInfo);
对于这一行:
finished = getInputBuffer(inputBuffer, isAudioSample, bufferInfo);
I didn't find this function getInputBuffer in both MediaCodec.java and MediaMuxer.java, is that a user defined function or API function? 我没有在MediaCodec.java和MediaMuxer.java中找到这个函数getInputBuffer,是用户定义的函数还是API函数?
In this case, getInputBuffer
is a hypothetical user defined function. 在这种情况下,
getInputBuffer
是一个假设的用户定义函数。 It is not an API function. 它不是API函数。 The comment above it explains what it is supposed to do.
上面的评论解释了它应该做什么。 (Note how it wouldn't actually work in the way it is written, since the isAudioSample variable can't be updated by the function in the way it is exactly written either.)
(注意它实际上不会以它的编写方式工作,因为isAudioSample变量不能被函数以完全写入的方式更新。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.