android.media.MediaExtractor.getSampleFlags()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(15.9k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中android.media.MediaExtractor.getSampleFlags()方法的一些代码示例,展示了MediaExtractor.getSampleFlags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaExtractor.getSampleFlags()方法的具体详情如下:
包路径:android.media.MediaExtractor
类名称:MediaExtractor
方法名:getSampleFlags

MediaExtractor.getSampleFlags介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

tracks[i].readSampleData(buffer, 0),
    tracks[i].getSampleTime(),
    tracks[i].getSampleFlags()
);

代码示例来源:origin: guoxiaoxing/phoenix

@SuppressLint("Assert")
@Override
public boolean stepPipeline() {
  if (mIsEOS) return false;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex < 0) {
    mBuffer.clear();
    mBufferInfo.set(0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    mMuxer.writeSampleData(mSampleType, mBuffer, mBufferInfo);
    mIsEOS = true;
    return true;
  }
  if (trackIndex != mTrackIndex) return false;
  mBuffer.clear();
  int sampleSize = mExtractor.readSampleData(mBuffer, 0);
  assert sampleSize <= mBufferSize;
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  int flags = isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0;
  mBufferInfo.set(0, sampleSize, mExtractor.getSampleTime(), flags);
  mMuxer.writeSampleData(mSampleType, mBuffer, mBufferInfo);
  mWrittenPresentationTimeUs = mBufferInfo.presentationTimeUs;
  mExtractor.advance();
  return true;
}

代码示例来源:origin: guoxiaoxing/phoenix

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: guoxiaoxing/phoenix

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: MasayukiSuda/GPUVideo-android

@SuppressLint("Assert")
public boolean stepPipeline() {
  if (isEOS) return false;
  int trackIndex = mediaExtractor.getSampleTrackIndex();
  if (trackIndex < 0) {
    buffer.clear();
    bufferInfo.set(0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    muxRender.writeSampleData(sampleType, buffer, bufferInfo);
    isEOS = true;
    return true;
  }
  if (trackIndex != this.trackIndex) return false;
  buffer.clear();
  int sampleSize = mediaExtractor.readSampleData(buffer, 0);
  assert sampleSize <= bufferSize;
  boolean isKeyFrame = (mediaExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  int flags = isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0;
  bufferInfo.set(0, sampleSize, mediaExtractor.getSampleTime(), flags);
  muxRender.writeSampleData(sampleType, buffer, bufferInfo);
  writtenPresentationTimeUs = bufferInfo.presentationTimeUs;
  mediaExtractor.advance();
  return true;
}

代码示例来源:origin: yangjie10930/OpenGL4Android

private boolean audioDecodeStep(ByteBuffer buffer) {
  boolean isTimeEnd = false;
  buffer.clear();
  synchronized (Extractor_LOCK) {
    mExtractor.selectTrack(mAudioDecoderTrack);
    int length = mExtractor.readSampleData(buffer, 0);
    if (length != -1) {
      int flags = mExtractor.getSampleFlags();
      mAudioEncoderBufferInfo.size = length;
      mAudioEncoderBufferInfo.flags = flags;
      mAudioEncoderBufferInfo.presentationTimeUs = mExtractor.getSampleTime();
      mAudioEncoderBufferInfo.offset = 0;
      isTimeEnd = mExtractor.getSampleTime() >= mVideoStopTimeStamp;
      mMuxer.writeSampleData(mAudioEncoderTrack, buffer, mAudioEncoderBufferInfo);
    }
    isAudioExtractorEnd = !mExtractor.advance();
  }
  return isAudioExtractorEnd || isTimeEnd;
}

代码示例来源:origin: ypresto/android-transcoder

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: MasayukiSuda/Mp4Composer-android

private int drainExtractor() {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mediaExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = decoder.dequeueInputBuffer(0);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mediaExtractor.readSampleData(decoderInputBuffers[result], 0);
  boolean isKeyFrame = (mediaExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, mediaExtractor.getSampleTime() / timeScale, isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mediaExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: windrunnerlihuan/DogCamera

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: GoBelieveIO/im_android

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: MasayukiSuda/GPUVideo-android

private int drainExtractor() {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mediaExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = decoder.dequeueInputBuffer(0);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mediaExtractor.readSampleData(decoderInputBuffers[result], 0);
  boolean isKeyFrame = (mediaExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, mediaExtractor.getSampleTime() / timeScale, isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mediaExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: LLhon/Android-Video-Editor

private int drainExtractor() {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mediaExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = decoder.dequeueInputBuffer(0);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mediaExtractor.readSampleData(decoderInputBuffers[result], 0);
  boolean isKeyFrame = (mediaExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, mediaExtractor.getSampleTime() / timeScale, isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mediaExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: kriztan/Pix-Art-Messenger

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
  boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: LLhon/Android-Video-Editor

private int drainExtractor(long timeoutUs) {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = extractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = decoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = extractor.readSampleData(decoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (extractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, extractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  extractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: GoBelieveIO/im_android

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: ypresto/android-transcoder

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: MasayukiSuda/Mp4Composer-android

private int drainExtractor(long timeoutUs) {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = extractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = decoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = extractor.readSampleData(decoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (extractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, extractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  extractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: windrunnerlihuan/DogCamera

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: MasayukiSuda/GPUVideo-android

private int drainExtractor(long timeoutUs) {
  if (isExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = extractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != this.trackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = decoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    isExtractorEOS = true;
    decoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = extractor.readSampleData(decoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (extractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  decoder.queueInputBuffer(result, 0, sampleSize, extractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  extractor.advance();
  return DRAIN_STATE_CONSUMED;
}

代码示例来源:origin: kriztan/Pix-Art-Messenger

private int drainExtractor(long timeoutUs) {
  if (mIsExtractorEOS) return DRAIN_STATE_NONE;
  int trackIndex = mExtractor.getSampleTrackIndex();
  if (trackIndex >= 0 && trackIndex != mTrackIndex) {
    return DRAIN_STATE_NONE;
  }
  final int result = mDecoder.dequeueInputBuffer(timeoutUs);
  if (result < 0) return DRAIN_STATE_NONE;
  if (trackIndex < 0) {
    mIsExtractorEOS = true;
    mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
    return DRAIN_STATE_NONE;
  }
  final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
  final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
  mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
  mExtractor.advance();
  return DRAIN_STATE_CONSUMED;
}

相关文章