Find the MediaCodec supported video encoding resolutions under Jelly Bean MR2 - android

Is there any way to get the MediaCodec video encoding supported resolutions under Jelly Bean MR2?
For lollipop we can use the new getVideoCapabilities() method to find out all the supported video resolutions. But for lower API levels couldn't find a way in the MediaCodec API.
I'm aware of the CamcorderProfile class available since API 8 which can give some hints of what the hardware might support, but to use the camcorder profiles to resolve the encoder video resolutions seems to be a guess game without consistency which could fail easily on many devices.

If it's listed in the CDD then you can assume it. If not, you have to try and see if it works.
The screenrecord tool uses a retry-on-error scheme to deal with cases where the video encoder can't record at the display resolution, because there was no way to query for it back then.

Related

Media codec capabilities Android

We are developing an application which involves audio,video decoding and encoding. In some cases we need multiple decoders to be open at same time.
Problem :
Some devices doesnt support multiple(2 or more) decoders to be open at same time. This happens mostly for high resolution videos (1080p).
Assumptions
We think this is happening because of hardware limitations of the devices.
We need to know is there any apis which tells us the media codec capabilities in android like maximum number of codecs that can be opened at same time in any android device. We are fine with even if the API is in native level.
How about MediaCodecInfo.CodecCapabilities.getMaxSupportedInstances()?

Android camera2 mediarecorder.setvideoencodingbitrate galaxy s6

I have found that setvideoencodingbitrate(800000) works for most of the devices I am using but on the Samsung Galaxy S6 it seems to record at 1.3 MBs rather than 800 kbs as set.
I am assuming this is because the device doesnt support that bit rate (I could be wrong)
Is there a way of getting an android devices supported videoencoding bitrates? or at least seeing what the MediaRecorder has been set to after calling on prepare? I cant seem to find any kind of mediaRecorder.getvideoencodingbitrate call?
Code below.
mediaRecorder.setVideoEncodingBitRate(500000); //500000 works with galaxy s6
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setVideoFrameRate(mCaptureProfile.framesPerSecond);
// Audio Settings
mediaRecorder.setAudioChannels(mCaptureProfile.audioNumChannels);
mediaRecorder.setAudioSamplingRate(mCaptureProfile.audioSampleRate);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediaRecorder.setAudioEncodingBitRate(mCaptureProfile.audioBitRate);
mediaRecorder.prepare();
In general, it's recommended you use CamcorderProfile to select the encoding settings, including bitrate, when recording video with a MediaRecorder. Select the profile with the resolution you want (for the camera you want), and then set it on the media recorder with MediaRecorder.setProfile.
This allows the device vendor to set the recommended bitrate, which may vary greatly between devices, due to different hardware encoders, supported parts of the video recording specs, and so on.
To look at the actual supported bitrates, that may be available somewhere in MediaCodecInfo.

Mime type video/avc supported by multiple encoders on my Android device

When I enumerate all the media codecs on my device, I noticed that mime type "video/avc" is supported by the following encoders:
OMX.qcom.video.encoder.avc
OMX.google.h264.encoder
When you call MediaCodec.CreateEncoderByType(), how does Android decide which encoder to pick?
Also, besides Google's encoder, many devices may have another encoder specific to the hardware, such as the one from Qualcomm in my case. Generally speaking, should one choose native encoder over the one from Google? Regards.
Tried it on a few different devices. It appears the native encoder always appears before the one from Google. This is the one that gets picked up. I guess native encoder is more optimized as it has more knowledge of the hardware.

How to do hardware h.264 video encoding on android platform

I'm trying to do hardware h.264 video encoding platform, I've learned that "MediaCodec" seems support hardware video decoding, but does it support hardware video encoding?
Some search results from google suggest I should consider search for different solutions for different chips according to user's Android device, does this mean I should go to each chip provider's website to search for different solution?
Thanks for any advice
The MediaCodec class also supports video encoding. The MediaCodec class was explicitly designed for multi device hardware accelerated media processing so that the same code runs on every device (from experience i can tell you it won't)
Good readings about this topic: http://developer.android.com/reference/android/media/MediaCodec.html
http://bigflake.com/mediacodec/
Remember, MediaCodec min-sdk version is 16 (i recommend to target api 18 e.g. usage of surface / MediaMuxer class), so if you're targeting devices with api < 16 MediaCodec won't do. If you wan't to target these devices you'll have to use lib stagefright and OpenMax wich i do not recomend

Record GLSurfaceView on < Android 4.3

I'm developing an app for applying effects to the camera image in real-time. Currently I'm using the MediaMuxer class in combination with MediaCodec. Those classes were implemented with Android 4.3.
Now I wanted to redesign my app and make it compatible for more devices. The only thing I found in the internet was a combination of FFmpeg and OpenCV, but I read that the framerate is not very well if I want to use a high resolution. Is there any possibility to encode video in real-time while capturing the camera image without using MediaMuxer and MediaCodec?
PS: I'm using GLSurfaceView for OpenGL fragment shader effects. So this is a must-have.
Real-time encoding of large frames at a moderate frame rate is not going to happen with software codecs.
MediaCodec was introduced in 4.1, so you can still take advantage of hardware-accelerated compression so long as you can deal with the various problems. You'd still need an alternative to MediaMuxer if you want a .mp4 file at the end.
Some commercial game recorders, such as Kamcord and Everyplay, claim to work on Android 4.1+. So it's technically possible, though I don't know if they used non-public APIs to feed surfaces directly into the video encoder.
In pre-Jellybean Android it only gets harder.
(For anyone interested in recording GL in >= 4.3, see EncodeAndMuxTest or Grafika's "Record GL app".)

Categories

Resources