I am currently working on video recording using MediaCodec and MediaMuxer because I need the recorder frames to use a t multiple places.
Current Behaviour : Media codec is configured with 720x1280 resolution, and media muxer video track added from the media codec, therefore the video output is also containg the same resolution 720x1280.
Creating media format
MediaFormat mVideoFormat = MediaFormat.createVideoFormat(VIDEO_MIME_TYPE, 720, 1280);
mVideoFormat.setInteger(MediaFormat.KEY_BIT_RATE, 1024*1024);
mVideoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
mVideoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 3);
mVideoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT,MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
Creating codec from media format
mMediaCodec = MediaCodec.createByCodecName(videoCodecInfo.getName());
mMediaCodec.setVideoScalingMode(MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
mMediaCodec.configure(mVideoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
mInputSurface = mMediaCodec.createInputSurface();
And adding track of muxer from
if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
MediaFormat mediaFormat = mMediaCodec.getOutputFormat();
mTrackIndex = mMediaMuxer.addVideoTrack(mediaFormat);
mMediaMuxer.start();
}
Expecting Output I always want media codec to run on the 720x1280, but I want media muxer to write video with different resolution like 720x1280 or any other resolution which is below it.
Over all goal which I want to achive is that I can configure MediaCodec to highest possible resolution, and on runtime I can create multiple video parallely with differnt resolutions.