Recording video using MediaCodec with Camera2 API
I am trying to use MediaCodec to record raw frames from ImageReader in onImageAvailable callback but unable to write a working code. Most of the examples are using Camera 1 API or MediaRecorder. My aim is to capture individual frames process it and create an mp4 out of it Raw YUV frames @Override public void onImageAvailable(ImageReader reader) { Image i = reader.acquireLatestImage(); processImage(i); i.close(); Log.d("hehe", "onImageAvailable"); } }; MediaCodec MediaCodec codec = MediaCodec.createByCodecName(name); MediaFormat mOutputFormat; // member variable codec.setCallback(new MediaCodec