1

I work on a project that requires to have exact seeking of a video because the system needs to be synchronized to other devices. The OS uses for video playback is Android. So far I used the MediaPlayer class, but depending on the key frame amount, seeking is highly inaccurate.

So my next idea is to cache decoded images and wrap an own playback class around it. So far I understand how to use the MediaExtractor and the MediaCodec classes to decode videos manually. The class android.media.ImageReader seems to be exactly what I want.

But what I do not understand is how to render such an android.media.Image manually once I've got it? I'd like to prevent to do the YUV to RGB conversion manually, instead a preferred method would be to be able to put such an Image into a Surface or copy it to a SurfaceTexture somehow.

Lyve
  • 218
  • 1
  • 11
  • never used it but there is getSurface() method so you can use it? – pskink Dec 09 '14 at 21:48
  • 1
    You have two approaches: (1) render everything from the previous key frame, storing all of the output; (2) skip back to the key frame every time and play forward, dropping all the frames you don't want. If the decoder is capable of decoding frames quickly enough, there's no need to store full uncompressed frames. For #1, ImageReader is probably what you'd want to use, but last I checked it only worked with the Camera, not MediaCodec (which uses different YUV formats). And there's no corresponding ImageWriter to put the data back onto a Surface. – fadden Dec 09 '14 at 23:48

1 Answers1

0

Please take a look here

In order to support use cases where need to sync videos being played on several devices this player makes exact seek

Zoe
  • 27,060
  • 21
  • 118
  • 148
Marlon
  • 1,473
  • 11
  • 13
  • 1
    The problem I found with this is that it only performs "seeking" when the video is playing. I have been looking for almost 2 weeks and still couldn't find a library or source online that shows how to perform exact seeking when a video is paused. – ClassA Aug 14 '18 at 13:35
  • 1
    Any luck on it @ClassA ? I am looking for the same – karanatwal.github.io Nov 01 '18 at 06:26
  • @karanatwal.github.io Yes I ended up building my own player using mediacodec. – ClassA Nov 01 '18 at 06:34
  • @ClassA Can you please post it as your answer ? Or answer my question https://stackoverflow.com/q/53096333/5996106 – karanatwal.github.io Nov 01 '18 at 06:42