Reputation: 2308
Android camera have a onPreviewFrame call back which gives you back a frame as byte[] data.
I have set up my Camera to return data (in NV21 format) byte[] data at 1280 x 720.
What I wanted to do:
I would like to keep some of the frames at 1280 x 720 resolution(to jpeg).
And generate a mp4 elementary stream at a lower resolution(something like 720 x 480).
Problem
MediaCodec would error out if the MediaFormat.Key_Width and MediaFormat.Key_Height is not equal to the onPreviewFrame's width and height.
I would like to know if its possible to scale my byte[] data(NV21) from 1280 x 720 to something lower like 720 x 480 resolution and then feed it to the encoder?
If it is possible, what are the steps for converting a byte[] data of NV21 at 1280 x 720 resolution to a lower resolution.
thanks for reading, and would appreciate any suggestions or helps.
Upvotes: 1
Views: 1455
Reputation: 637
Yes, it is possible. Have a look at library https://code.google.com/p/libyuv/. It can scale yuv images, convert between different color formats also it has SIMD optimisations (it is pretty fast).
Upvotes: 0