简体   繁体   English

Android MediaCodec和MediaMuxer中的getInpuBuffer

[英]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.

相关问题 android 中的 MediaCodec、MediaExtractor 和 MediaMuxer 是什么? - What is MediaCodec, MediaExtractor and MediaMuxer in android? Android MediaCodec MediaMuxer致命信号11(SIGSEGV) - Android MediaCodec MediaMuxer Fatal Signal 11 (SIGSEGV) 使用Android的MediaCodec和MediaMuxer复用AAC音频 - Muxing AAC audio with Android's MediaCodec and MediaMuxer Android:使用MediaCodec和MediaMuxer录制时裁剪视频 - Android: Crop video while recording using MediaCodec and MediaMuxer android SDK 中的 MediaExtractor、MediaCodec 和 MediaMuxer 之间有什么关系? - What is relation between MediaExtractor, MediaCodec and MediaMuxer in android SDK? Android Camera2 + MediaCodec + MediaMuxer 使用持久表面? - Android Camera2 + MediaCodec + MediaMuxer using persistent surface? 使用MediaCodec和MediaMuxer的图像到视频 - Images to Video using MediaCodec and MediaMuxer 使用mediacodec和mediamuxer同步音频和视频 - sync audio and video with mediacodec and mediamuxer Android:MediaCodec + MediaMuxer编码的音频MP4无法播放 - Android: MediaCodec+MediaMuxer encoded audio MP4 won't play Android使用mediamuxer mediacodec和mediaextractor(没有mp4parser)合并mp4和aac文件 - Android merging mp4 and aac file using mediamuxer mediacodec and mediaextractor (without mp4parser)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM