1

I want to play back a video in Android, rendering it to a SurfaceTexture or something else that is usable as an OpenGL ES texture, but I need very precise control over the playback speed of the video to synchronize it to a stream of external events. These events will happen at a roughly predictable speed, but the exact speed will depend on many small mechanical details, influenced by many small factors, including the weather (and possibly even the phase of the moon...).

The android.media.MediaPlayer class provided by android allows rendering to a SurfaceTexture (and the 360Videos app from the Oculus Mobile SDK successfully uses that feature), but unfortunately does not seem to allow altering the playback speed, at least not as far as I could tell from the documentation here.

I have tried pausing and resuming the playback using pause() and start() respectively, to influence the playback speed, but that leads to extremely choppy and slow playback. My idea here was to make the video have a higher framerate than would ever be needed, and to then manually retard every frame until it actually needs to be shown. From the messages in the log, it looks to me like the MediaPlayer class will release various needed resources on pause and rerequest them on resume, which obviously kills performance if you do that once per frame.

Another option I am looking at is ffmpeg. This one seems like it will do what i want, it doesn't do any timings itself, it just decodes frames whenever I tell it to to a buffer, leaving me to use it however I want, whenever I want. The obvious drawback is that ffmpeg, at least on android, doesn't do hardware decoding and probably won't be able to decode 4K media in realtime.

Yet another thing I was looking at was OpenMAX AL. Unfortunately, OpenMax AL is pretty hard to get into. I haven't found any good beginner's documentation yet, only some old, maybe outdated, READMEs as well as the interface specification from Khronos. The latter is a very long and cumbersome read, though, and I couldn't yet even figure out if OpenMAX AL will even allow me to do my own timings...

1
  • You can do it by ffmpeg lib. There is ready example of android player using ffmpeg in github.com.
    – support_ms
    Mar 23, 2016 at 4:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.