public class CamcorderProfile extends Object
The compressed output from a recording session with a given CamcorderProfile contains two tracks: one for audio and one for video.
Each profile specifies the following set of parameters:
Modifier and Type | Field and Description |
---|---|
int |
audioBitRate
The target audio output bit rate in bits per second
|
int |
audioChannels
The number of audio channels used for the audio track
|
int |
audioCodec
The audio encoder being used for the audio track.
|
int |
audioSampleRate
The audio sampling rate used for the audio track
|
int |
duration
Default recording duration in seconds before the session is terminated.
|
int |
fileFormat
The file output format of the camcorder profile
|
int |
quality
The quality level of the camcorder profile
|
static int |
QUALITY_1080P
Quality level corresponding to the 1080p (1920 x 1080) resolution.
|
static int |
QUALITY_2160P
Quality level corresponding to the 2160p (3840x2160) resolution.
|
static int |
QUALITY_480P
Quality level corresponding to the 480p (720 x 480) resolution.
|
static int |
QUALITY_720P
Quality level corresponding to the 720p (1280 x 720) resolution.
|
static int |
QUALITY_CIF
Quality level corresponding to the cif (352 x 288) resolution.
|
static int |
QUALITY_HIGH
Quality level corresponding to the highest available resolution.
|
static int |
QUALITY_HIGH_SPEED_1080P
High speed ( >= 100fps) quality level corresponding to the 1080p (1920 x 1080 or 1920x1088)
resolution.
|
static int |
QUALITY_HIGH_SPEED_2160P
High speed ( >= 100fps) quality level corresponding to the 2160p (3840 x 2160)
resolution.
|
static int |
QUALITY_HIGH_SPEED_480P
High speed ( >= 100fps) quality level corresponding to the 480p (720 x 480) resolution.
|
static int |
QUALITY_HIGH_SPEED_720P
High speed ( >= 100fps) quality level corresponding to the 720p (1280 x 720) resolution.
|
static int |
QUALITY_HIGH_SPEED_HIGH
High speed ( >= 100fps) quality level corresponding to the highest available resolution.
|
static int |
QUALITY_HIGH_SPEED_LOW
High speed ( >= 100fps) quality level corresponding to the lowest available resolution.
|
static int |
QUALITY_LOW
Quality level corresponding to the lowest available resolution.
|
static int |
QUALITY_QCIF
Quality level corresponding to the qcif (176 x 144) resolution.
|
static int |
QUALITY_QVGA
Quality level corresponding to the QVGA (320x240) resolution.
|
static int |
QUALITY_TIME_LAPSE_1080P
Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution.
|
static int |
QUALITY_TIME_LAPSE_2160P
Time lapse quality level corresponding to the 2160p (3840 x 2160) resolution.
|
static int |
QUALITY_TIME_LAPSE_480P
Time lapse quality level corresponding to the 480p (720 x 480) resolution.
|
static int |
QUALITY_TIME_LAPSE_720P
Time lapse quality level corresponding to the 720p (1280 x 720) resolution.
|
static int |
QUALITY_TIME_LAPSE_CIF
Time lapse quality level corresponding to the cif (352 x 288) resolution.
|
static int |
QUALITY_TIME_LAPSE_HIGH
Time lapse quality level corresponding to the highest available resolution.
|
static int |
QUALITY_TIME_LAPSE_LOW
Time lapse quality level corresponding to the lowest available resolution.
|
static int |
QUALITY_TIME_LAPSE_QCIF
Time lapse quality level corresponding to the qcif (176 x 144) resolution.
|
static int |
QUALITY_TIME_LAPSE_QVGA
Time lapse quality level corresponding to the QVGA (320 x 240) resolution.
|
int |
videoBitRate
The target video output bit rate in bits per second
This is the target recorded video output bit rate if the application configures the video
recording via
MediaRecorder.setProfile(android.media.CamcorderProfile) without specifying any other
MediaRecorder encoding parameters. |
int |
videoCodec
The video encoder being used for the video track
|
int |
videoFrameHeight
The target video frame height in pixels
|
int |
videoFrameRate
The target video frame rate in frames per second.
|
int |
videoFrameWidth
The target video frame width in pixels
|
Modifier and Type | Method and Description |
---|---|
static CamcorderProfile |
get(int quality)
Returns the camcorder profile for the first back-facing camera on the
device at the given quality level.
|
static CamcorderProfile |
get(int cameraId,
int quality)
Returns the camcorder profile for the given camera at the given
quality level.
|
static boolean |
hasProfile(int quality)
Returns true if camcorder profile exists for the first back-facing
camera at the given quality level.
|
static boolean |
hasProfile(int cameraId,
int quality)
Returns true if camcorder profile exists for the given camera at
the given quality level.
|
public static final int QUALITY_LOW
public static final int QUALITY_HIGH
public static final int QUALITY_QCIF
public static final int QUALITY_CIF
public static final int QUALITY_480P
public static final int QUALITY_720P
public static final int QUALITY_1080P
public static final int QUALITY_QVGA
public static final int QUALITY_2160P
public static final int QUALITY_TIME_LAPSE_LOW
public static final int QUALITY_TIME_LAPSE_HIGH
public static final int QUALITY_TIME_LAPSE_QCIF
public static final int QUALITY_TIME_LAPSE_CIF
public static final int QUALITY_TIME_LAPSE_480P
public static final int QUALITY_TIME_LAPSE_720P
public static final int QUALITY_TIME_LAPSE_1080P
public static final int QUALITY_TIME_LAPSE_QVGA
public static final int QUALITY_TIME_LAPSE_2160P
public static final int QUALITY_HIGH_SPEED_LOW
For all the high speed profiles defined below ((from QUALITY_HIGH_SPEED_LOW
to
QUALITY_HIGH_SPEED_2160P
), they are similar as normal recording profiles, with just
higher output frame rate and bit rate. Therefore, setting these profiles with
MediaRecorder.setProfile(android.media.CamcorderProfile)
without specifying any other encoding parameters will
produce high speed videos rather than slow motion videos that have different capture and
output (playback) frame rates. To record slow motion videos, the application must set video
output (playback) frame rate and bit rate appropriately via
MediaRecorder.setVideoFrameRate(int)
and MediaRecorder.setVideoEncodingBitRate(int)
based on the slow motion factor. If the application intends to do the video recording with
MediaCodec
encoder, it must set each individual field of MediaFormat
similarly according to this CamcorderProfile.
public static final int QUALITY_HIGH_SPEED_HIGH
public static final int QUALITY_HIGH_SPEED_480P
public static final int QUALITY_HIGH_SPEED_720P
public static final int QUALITY_HIGH_SPEED_1080P
public static final int QUALITY_HIGH_SPEED_2160P
public int duration
public int quality
public int fileFormat
MediaRecorder.OutputFormat
public int videoCodec
MediaRecorder.VideoEncoder
public int videoBitRate
This is the target recorded video output bit rate if the application configures the video
recording via MediaRecorder.setProfile(android.media.CamcorderProfile)
without specifying any other
MediaRecorder
encoding parameters. For example, for high speed quality profiles (from
QUALITY_HIGH_SPEED_LOW
to QUALITY_HIGH_SPEED_2160P
), this is the bit rate
where the video is recorded with. If the application intends to record slow motion videos
with the high speed quality profiles, it must set a different video bit rate that is
corresponding to the desired recording output bit rate (i.e., the encoded video bit rate
during normal playback) via MediaRecorder.setVideoEncodingBitRate(int)
. For example, if
QUALITY_HIGH_SPEED_720P
advertises 240fps videoFrameRate
and 64Mbps
videoBitRate
in the high speed CamcorderProfile, and the application intends to
record 1/8 factor slow motion recording videos, the application must set 30fps via
MediaRecorder.setVideoFrameRate(int)
and 8Mbps ( videoBitRate
* slow motion
factor) via MediaRecorder.setVideoEncodingBitRate(int)
. Failing to do so will result in
videos with unexpected frame rate and bit rate, or MediaRecorder
error if the output
bit rate exceeds the encoder limit. If the application intends to do the video recording with
MediaCodec
encoder, it must set each individual field of MediaFormat
similarly according to this CamcorderProfile.
videoFrameRate
,
MediaRecorder
,
MediaCodec
,
MediaFormat
public int videoFrameRate
This is the target recorded video output frame rate per second if the application configures
the video recording via MediaRecorder.setProfile(android.media.CamcorderProfile)
without specifying any other
MediaRecorder
encoding parameters. For example, for high speed quality profiles (from
QUALITY_HIGH_SPEED_LOW
to QUALITY_HIGH_SPEED_2160P
), this is the frame rate
where the video is recorded and played back with. If the application intends to create slow
motion use case with the high speed quality profiles, it must set a different video frame
rate that is corresponding to the desired output (playback) frame rate via
MediaRecorder.setVideoFrameRate(int)
. For example, if QUALITY_HIGH_SPEED_720P
advertises 240fps videoFrameRate
in the CamcorderProfile, and the application
intends to create 1/8 factor slow motion recording videos, the application must set 30fps via
MediaRecorder.setVideoFrameRate(int)
. Failing to do so will result in high speed videos
with normal speed playback frame rate (240fps for above example). If the application intends
to do the video recording with MediaCodec
encoder, it must set each individual field
of MediaFormat
similarly according to this CamcorderProfile.
videoBitRate
,
MediaRecorder
,
MediaCodec
,
MediaFormat
public int videoFrameWidth
public int videoFrameHeight
public int audioCodec
MediaRecorder.AudioEncoder
public int audioBitRate
public int audioSampleRate
public int audioChannels
public static CamcorderProfile get(int quality)
quality
- the target quality level for the camcorder profileget(int, int)
public static CamcorderProfile get(int cameraId, int quality)
hasProfile(int, int)
.
QUALITY_LOW refers to the lowest quality available, while QUALITY_HIGH refers to
the highest quality available.
QUALITY_LOW/QUALITY_HIGH have to match one of qcif, cif, 480p, 720p, 1080p or 2160p.
E.g. if the device supports 480p, 720p, 1080p and 2160p, then low is 480p and high is
2160p.
The same is true for time lapse quality levels, i.e. QUALITY_TIME_LAPSE_LOW,
QUALITY_TIME_LAPSE_HIGH are guaranteed to be supported and have to match one of
qcif, cif, 480p, 720p, 1080p, or 2160p.
For high speed quality levels, they may or may not be supported. If a subset of the levels
are supported, QUALITY_HIGH_SPEED_LOW and QUALITY_HIGH_SPEED_HIGH are guaranteed to be
supported and have to match one of 480p, 720p, or 1080p.
A camcorder recording session with higher quality level usually has higher output
bit rate, better video and/or audio recording quality, larger video frame
resolution and higher audio sampling rate, etc, than those with lower quality
level.cameraId
- the id for the cameraquality
- the target quality level for the camcorder profile.QUALITY_LOW
,
QUALITY_HIGH
,
QUALITY_QCIF
,
QUALITY_CIF
,
QUALITY_480P
,
QUALITY_720P
,
QUALITY_1080P
,
QUALITY_2160P
,
QUALITY_TIME_LAPSE_LOW
,
QUALITY_TIME_LAPSE_HIGH
,
QUALITY_TIME_LAPSE_QCIF
,
QUALITY_TIME_LAPSE_CIF
,
QUALITY_TIME_LAPSE_480P
,
QUALITY_TIME_LAPSE_720P
,
QUALITY_TIME_LAPSE_1080P
,
QUALITY_TIME_LAPSE_2160P
,
QUALITY_HIGH_SPEED_LOW
,
QUALITY_HIGH_SPEED_HIGH
,
QUALITY_HIGH_SPEED_480P
,
QUALITY_HIGH_SPEED_720P
,
QUALITY_HIGH_SPEED_1080P
,
QUALITY_HIGH_SPEED_2160P
public static boolean hasProfile(int quality)
When using the Camera 2 API in LEGACY
mode (i.e. when
CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
is set
to
CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY
),
hasProfile(int)
may return true
for unsupported resolutions. To ensure a
a given resolution is supported in LEGACY mode, the configuration given in
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP
must contain the the resolution in the supported output sizes. The recommended way to check
this is with
StreamConfigurationMap.getOutputSizes(Class)
with the
class of the desired recording endpoint, and check that the desired resolution is contained
in the list returned.
quality
- the target quality level for the camcorder profileCameraManager
,
CameraCharacteristics
public static boolean hasProfile(int cameraId, int quality)
When using the Camera 2 API in LEGACY mode (i.e. when
CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
is set
to
CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY
),
hasProfile(int)
may return true
for unsupported resolutions. To ensure a
a given resolution is supported in LEGACY mode, the configuration given in
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP
must contain the the resolution in the supported output sizes. The recommended way to check
this is with
StreamConfigurationMap.getOutputSizes(Class)
with the
class of the desired recording endpoint, and check that the desired resolution is contained
in the list returned.
cameraId
- the id for the cameraquality
- the target quality level for the camcorder profileCameraManager
,
CameraCharacteristics