Firstly, I'm aware that there are similar questions asked before. But my question is about performance.
I'm using MediaCodec
to seek through a video, this works perfectly when seeking forward. But when seeking backward, it is "choppy"/"laggy".
This is 'kind of' expected because, when seeking backwards, I seek to the previous key/sync frame and then seek forward to the desired frame, like this:
extractorSeekTo(timestamp, MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
mDecoder.flush();
//continue feeding without rendering:
//mDecoder.releaseOutputBuffer(bufferIndex, false);
//until target frame is reached
Extra context:
I'm testing with a video that only has 2 key frames. When seeking backwards, it would jump all the way back to the closest key frame and then seek forward. The time it takes depends on how "close" the desired buffer is to the key frame.
I've seen some applications that perform backward seeking without having the jump/lag effect. I decompiled these applications to see if they use native code and they all do. That got me thinking that MediaCodec
is not performing optimally.
So, my question is (the obvious question would be 'how these applications do it', but..):
- Would implementing
MediaCodec
using ndk/natively resolve this issue? (improve the performance) - If not, does anyone have any suggestions on how the lag can be overcome?
from MediaCodec seeking backwards
No comments:
Post a Comment