Android: How to decect video size with Android Camera API

225 Views Asked by At

is there a way to record a video with android Camera2 API or AndroidX Camera and obtain the file size while taking the video?

I want to have something like this: The user records a video and sees while recoding the file size of the current capture.

Is there any callback that gives the file size of the temp video file? Or is there a chance to pass some kind of "TempFileObserver"? Or an existing lib?

Kind regards for reading and sharing your experience. PS: I don't need a total implementation, reference is enough

1

There are 1 best solutions below

0
On BEST ANSWER

You can achieve this by method getBytes in ByteBuffer, mediacodec.getOutPutBuffer, bufferinfo, dequeoutputbuffer on every drain encode on every frame capturing through MediaCodec

Also you can try by using the ImageReader.onimageavailable..in this imagereader return the byte buffer on latest image capture

Please refer below link for detail about it

https://developer.android.com/reference/android/media/ImageReader.OnImageAvailableListener