You can run the MediaRecorder to create the video using h264 hardware encoder (if available) and at the same time register your preview frame handler. I cannot guarantee that all preview frames will go in both directions, though.
Alternatively, you can compile ffmpeg with libstagefright, and it will use hardware avc encoder.
Alternatively, you can use stagefright directly from your app (via JNI).
Finally, you can follow the approach of libstreaming to find the optimal recording API for your platform (be it MediaRecorder API, or MediaCodec buffer-to-buffer method which requires Android 4.1, or MediaCodec surface-to-buffer method which requires Android 4.3.