14

My app uses HLS to stream video from a server, but when I request the HLS stream from the server I need to pass it the max video bitrate the device can handle. In the Android API guides it says that "a device's available video recording profiles can be used as a proxy for media playback capabilities," but when I try to retrieve the videoBitRate for the devices back-facing camera it always comes back as 12Mb/s regardless of the device (Galaxy Nexus, Galaxy Tab Plus 7", Galaxy Tab 8.9), despite the fact that they have 3 different GPUs (PowerVR SGX540, Mali-400 MP, Tegra 250 T20). Here's my code, am I doing something wrong?

CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
targetVideoBitRate = camcorderProfile.videoBitRate;

If I try this on the Galaxy Tab Plus:

boolean hasProfile = CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH);

it returns True, despite the fact that QUALITY_HIGH is for 1080p recording and the specs say it can only record at 720p.

1
  • 6
    a cellphone to be launched with the android OS must provide some values like that one. sometimes the brands just put some random value on that fields. I faced a similar problem when trying to obtain the camera field-of-view angle where they put values like 10 degrees, which is unaccpetable. You probably have the same issue. they don't give a shit. they just want to put a smartphone on the market and don't care about programmers Jul 12, 2013 at 0:41

1 Answer 1

8
+400

It looks like I've found the answer to my own question.

I didn't read the documentation closely enough, QUALITY_HIGH is not equivalent to 1080p it is simply a way of specifying the highest quality profile the device supports. Therefore, by definition, CamcorderProfile.hasProfile( CamcorderProfile.QUALITY_HIGH ) is always true. I should have written something like this:

public enum mVideoQuality { 
    FullHD, HD, SD
}
mVideoQuality mMaxVideoQuality;
int mTargetVideoBitRate;

private void initVideoQuality {
    if ( CamcorderProfile.hasProfile( CamcorderProfile.QUALITY_1080P ) ) {
        mMaxVideoQuality = mVideoQuality.FullHD;
    } else if ( CamcorderProfile.hasProfile( CamcorderProfile.QUALITY_720P ) ) {
        mMaxVideoQuality = mVideoQuality.HD;
    } else {
        mMaxVideoQuality = mVideoQuality.SD;
    }
    CamcorderProfile cProfile = CamcorderProfile.get( CamcorderProfile.QUALITY_HIGH );
    mTargetVideoBitRate = cProfile.videoBitRate;
}

Most of my devices are still reporting support for 1080p encoding, which I'm skeptical of, however I ran this code on a Sony Experia Tipo ( my low end test device ) and it reported a max encode quality of 480p with a videoBitRate of 720Kb/s.

As I said, I'm not sure if every device can be trusted, but I have seen a range of video bitrates from 720Kb/s to 17Mb/s and Profile qualities from 480p - 1080p. Hopefully other people will find this information to be useful.

2
  • Please leave a comment if you have suggestions for improving my answer. Jul 16, 2013 at 18:37
  • Full disclosure: adogden and I work on the same team. I put a bounty on this question to help us get past this annoying problem. That probably prompted adogden to take another look and to write this helpful answer. He earned the bounty, and I'm awarding it to him, without the intent of transferring rep. Jul 18, 2013 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.