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

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

Related

Opentok SDK making Android and iOS devices too hot

I am using Opentok SDK for video calling in IOS and Android devices with Nodejs server.
It is a group call scenario with max 4 people, when we stream for more than 10 min, both the devices getting too hot.
Does anyone have solution for this?
We can't degrade the video quality.
This is likely because you are using the default video code, VP8, which is not hardware accelerated. You can change the codec per publisher to either H.264 or VP8, but there are some trade-offs to this approach.
Their lack of H.264 SVC support is disappointing, but might be okay depending on your use case. If you read this whole post and still want more guidance, I'd recommend reaching out to their developer support team, and/or post more about your use case here.
Here's some more context from the OpenTok Documentation, but I recommend you read the whole page to understand where you need to make compromises:
The VP8 real-time video codec is a software codec. It can work well at lower bitrates and is a mature video codec in the context of WebRTC. As a software codec it can be instantiated as many times as is needed by the application within the limits of memory and CPU. The VP8 codec supports the OpenTok Scalable Video feature, which means it works well in large sessions with supported browsers and devices.
The H.264 real-time video codec is available in both hardware and software forms depending on the device. It is a relatively new codec in the context of WebRTC although it has a long history for streaming movies and video clips over the internet. Hardware codec support means that the core CPU of the device doesn’t have to work as hard to process the video, resulting in reduced CPU load. The number of hardware instances is device-dependent with iOS having the best support. Given that H.264 is a new codec for WebRTC and each device may have a different implementation, the quality can vary. As such, H.264 may not perform as well at lower bit-rates when compared to VP8. H.264 is not well suited to large sessions since it does not support the OpenTok Scalable Video feature.

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()?

streaming video from android camera to pc?

What is the best (performance wise) way to get and stream a video from an android device's camera to a PC?
I have seen this question asked here before and there exist a few open source programs that do just that, but there exist multiple ways from which I don't know which one is the best!
for example:
Should the android part be written in c++ or java (performance/api wise)?
Which api should I use to get the video from camera?
What is the best way to stream the video?
I don't intend to support old android versions (<4.x), so if the best way/api is relatively new it's fine by me.
I'm not familiar with Android development but I'll try to answer.
I suppose that the actual encoding of the raw image data is probably done on hardware chip (otherwise software encoding would probably kill your battery) and it looks like MediaCodec class is exactly what you need. I suppose you want to implement some kind of live streaming service and the latency is important. If so, then you should stick to UDP based transmission methods. Using RTP protocol or MPEG-TS container format would be the best choice for this purpose. Of course you can also use TCP based methods for streaming like HLS or DASH (both of them use HTTP).
You should also take a look at Table 1 Core media format and codec support:
It tells us for example that using H.264 AVC Encoder supports MPEG-TS container and that HLS version 3 is also supported for Android 4.0 and above.

Find the MediaCodec supported video encoding resolutions under Jelly Bean MR2

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.

add a new codec to Android?

I'm very new to Android. Now i need to work on Adding my own codec to Android.I mean, I want to know what all the steps i need to take to add my own codec to android.
I'm very fresh to this i need some basic things, so can someone please explain the steps I need to take in order to add a new codec to Android?
This is virtually impossible to do in a portable way as all audio and video codecs are compiled at the platform level (due to the fact that most of the time they require hardware specific acceleration)
If you are only interested on this working on a specific hardware platform and have an unlocked bootloader (So you can boot a custom build of Android) you can compile the full Android platform from scratch using the AOSP as a base.
Depending on which version of Android you're targeting you're looking at adding code to either Opencore or Stagefright (The subsystems that Android uses for A/V decoding and parsing) here you can add audio decoders, audio encoders, video encoders, video decoders and container parsers.
Here is some discussion of adding to Stagefright:
http://freepine.blogspot.com/2010/01/overview-of-stagefrighter-player.html
http://groups.google.com/group/android-porting/msg/5d88e76845a22bbb
However unless the encoding scheme you wish to support is very simple (What are you wanting to add?) it is likely to be too CPU intensive for most Android devices to run without being able to offload some of the work to another system (like the radio chipset or the GPU).
In Android Framework, mediacodec is implemented as Stagefright, a media playback engine at the native level that has built-in software-based codecs for popular media formats. Stagefright also supports integration with custom hardware codecs provided as OpenMAX component. Here is the article which summaries the steps.
CHECK HERE

Categories

Resources