Reputation: 569
My goal is to get access to every single frame while recording a video.
I'm using Camera2
API.
What I want is to take every single frame while recording, and the frames should be exactly equal to each frame of result video, not preview frames.
Of course I can access each frame after recording is over using tools like OpenCV or FFMPEG or something, but right now I need to get them real-time while recording.
Bitmap
, Image
, ByteBuffer
, byte[]
or as file, whatever type is OK if I can access each data.
I've searched some tutorials and found this series, especially this video, but that's not exactly what I need. That tutorial includes how to take a photo while recording a video.
Can anybody help me?
Upvotes: 3
Views: 769
Reputation: 18117
Unfortunately, in general the exact video frames are only sent to the video encoder. You can of course decode the video after each encoded frame is output from a MediaCodec, but that's a bit expensive.
Alternatively, you can try using an ImageReader with usage flags, which is only possible on fairly recent Android versions, and use both the USAGE_CPU_READ_OFTEN and USAGE_VIDEO_ENCODE usage flags, and format YUV_420_888. That should be as close as you can get to the 'normal' video recording output, but it may not be exactly identical, unfortunately.
Upvotes: 1