Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing video frame by frame

I want to make app with frame by frame playback feature. I guess it's not possible with standard android tools. I tried VideoView and seekTo(current + 1000/framerate) method, but it doesn't work (i guess it won't seek on paused video). My question is: What do i need to learn and use to make it possible, what tools and/or libs? I'm android beginner and i didn't work on video rendering earlier so my knowledge about this is really low.

like image 716
kborkows Avatar asked Aug 08 '13 11:08

kborkows


1 Answers

A few years passed ,but the issue is still there

A short review about the topic:
Assuming you have a compressed video, like mp4 file. What you asking for, is to play frame by frame, but because of the compression, the frames are not actually there (look about i,p and b frames at this Wiki). So Android need to generate this frames for you. This generation may be far from optimal (it skipped about 3% frames in my case), and may not be supported on some devices , because there are different codecs used.

In case you are planning to run some Algo over it, I suggest extracting the frames first, as a jpg images, and then read them one by one.

I used the ffmpeg wrapper from here by hiteshsondhi88 to archive the extraction. It's very easy to use, and works smoothly.

In case your still want to go with pure Java, there is a great job done by Fadden. There is a few examples how to use media codec and get frames.

Moreover, I've written a small example on this, that can be found at my Git repository

There is also a discussion about it that in another StackOverflow question, but I have not tried it yet, to approve.

like image 114
Arkady Avatar answered Oct 21 '22 04:10

Arkady