Search code examples
javaandroidandroid-mediacodec

Set the start frame MediaCodec


I would like to know if there is a way to set the first frame that I want to decode.

Lets say that I want to start from frame number 300, Is there a way to set frame 300 as the first frame? or I there is a need to go through all the frames until I reach the desired frame?

Thanks


Solution

  • Using MediaExtractor, you can seek to a specific time. If your input has a fixed rate (e.g. it's 30fps video), this should be reasonably accurate.

    If it's video, and you didn't happen to land on an I-frame, I'm not sure what happens if you start feeding the video decoder from that point.

    If you need to be sure you're starting at exactly frame 300, you'll need to advance through the first 299 frames.