以下是一段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();对于这一行:finished = getInputBuffer(inputBuffer, isAudioSample, bufferInfo);我在MediaCodec.java和MediaMuxer.java中都没有找到这个函数getInputBuffer,这是一个用户定义的函数还是API函数?
发布于 2017-02-08 20:41:54
在本例中,getInputBuffer是一个假设的用户定义函数。它不是API函数。上面的注释解释了它应该做什么。(请注意,它实际上不会以编写的方式工作,因为isAudioSample变量也不能以确切的编写方式由函数更新。)
https://stackoverflow.com/questions/42111159
复制相似问题