I am trying to achieve smooth video scrubbing with Android VideoView
. The seekTo
method of MediaPlayer
is not doing exactly what i want. It does not exactly seek to millisecond i passed in it, it actually plays from/jumps to the nearest position, not the exact I seeked to. Also the frames are showing with a large gaps. Not the exact frame for millisecond.
I came on searching around and found that SEEK_CLOSEST_SYNC
can only seek to the nearest sync frame not the EXACT. It depends on the way the video was generated.
How can i achieve the smooth scrubbing and seek to exact position Even video is paused or playing. Is it possible through Android VideoView
or MediaPlayer
class or should i change the approach?
This is not a straight forward question to answer. I spent a month researching and implementing it myself.
The only way this can be achieved is using MediaCodec.
You can look at this project that does exact scrubbing using
MediaCodec
. The only issue I had with that project is that it takes time to load the buffer and display it on the surface, about 0.5 seconds.You can also have a look at Grafica, especially the
MoviePlayer
class. Another source is the BigFlake website.What I ended up doing is creating my own implementation using
MediaCodec
as none of them provided me exactly what I was looking for, as I was building a golf analyzer, I needed (real-time) precise (frame-per-frame) scrubbing of the video.You can also look at a question I asked that is similar to this, where I added a lot of info on how I achieved this. Though this question is more about playing a video frame-per-frame, I think there is valuable info in it.