You can use Android's MediaMuxer to package the raw streams created by MediaCodec into a .mp4 file.
stackoverflow.com