Copy consecutive frames from video

I am trying to copy part of a video and save it as a GIF to disk. The video can be local or remote, and the copy should be no more than 2 seconds. I don't need to save every frame, but every other frame (12-15fps). I have a "frames to gif" part, but the "get the frames" part is small.

Here's what I've tried so far:
- MediaMetadataRetriever

: too slow (~ 1s per frame on Nexus4) and only works with local files
- FFmpegMediaMetadataRetriever

: same latency, but works with remote video
- TextureView.getBitmap()

: I use ScheduledExecutorService

and every 60ms, grab Bitmap

(in playing time ...) It works well with small size getBitmap(100, 100)

, but for larger ones (> 400), the whole process becomes very slow. And, as they say in the document Do not invoke this method from a drawing method

.

It seems like the best solution would be to access every frame while decoding and store them. I tried OpenCV for Android , but couldn't find an API to capture a frame at a specific time.

Now I go through those samples to figure out how to use MediaCodec

, but while working ExtractMpegFramesTest.java

I can It seems that you are fetching some frame ("no exit from decoder").

Am I on the right track? Any other suggestion?

edit: moved on with ExtractMpegFramesTest.java

, thanks for the post.

edit 2: just to clarify what I'm trying to achieve here is to play the video and click a button to start capturing frames.

+1
android opencv video-capture mediacodec


source to share


No one has answered this question yet

See similar questions:

21
SurfaceTexture's onFrameAvailable () method is always called too late
2
Problems with MediaExtractor

or similar:

2735
Stop EditText from getting focus when starting Activity
6
Fastest way to draw MediaCodec decoded video clip to screen?
4
How to play raw h264 generated by MediaCodec encoder?
3
Retrieving frames from video, not from MediaMetadataRetriever
2
Number of input / output frames of Android MediaCodec decoder
2
Android TextureView: video displaying gray frame on getBitmap call
2
Skip frames when playing video with MediaExtractor and MediaCodec
1
Show video effect once for every frame in Grafika - CameraCaptureActivity
1
Got Invalid Frame Data with ExtractMpegFramesTest in Android?
0
Corrupted video decoding with MediaCodec in Android 5+



All Articles
Loading...
X
Show
Funny
Dev
Pics