feat(android): add videoBitrate option for recordAsync (#2055) [skip release]
This commit is contained in:
parent
fbc5c0d66b
commit
d93a6c7e11
@ -858,11 +858,14 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
|
||||
mMediaRecorder.setOutputFile(path);
|
||||
mVideoPath = path;
|
||||
|
||||
CamcorderProfile camProfile;
|
||||
if (CamcorderProfile.hasProfile(mCameraId, profile.quality)) {
|
||||
setCamcorderProfile(CamcorderProfile.get(mCameraId, profile.quality), recordAudio);
|
||||
camProfile = CamcorderProfile.get(mCameraId, profile.quality);
|
||||
} else {
|
||||
setCamcorderProfile(CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH), recordAudio);
|
||||
camProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH);
|
||||
}
|
||||
camProfile.videoBitRate = profile.videoBitRate;
|
||||
setCamcorderProfile(camProfile, recordAudio);
|
||||
|
||||
mMediaRecorder.setOrientationHint(calcCameraRotation(mOrientation != Constants.ORIENTATION_AUTO ? orientationEnumToRotation(mOrientation) : mDeviceOrientation));
|
||||
|
||||
|
||||
@ -1103,11 +1103,12 @@ class Camera2 extends CameraViewImpl implements MediaRecorder.OnInfoListener, Me
|
||||
mMediaRecorder.setOutputFile(path);
|
||||
mVideoPath = path;
|
||||
|
||||
if (CamcorderProfile.hasProfile(Integer.parseInt(mCameraId), profile.quality)) {
|
||||
setCamcorderProfile(profile, recordAudio);
|
||||
} else {
|
||||
setCamcorderProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH), recordAudio);
|
||||
CamcorderProfile camProfile = profile;
|
||||
if (!CamcorderProfile.hasProfile(Integer.parseInt(mCameraId), profile.quality)) {
|
||||
camProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
|
||||
}
|
||||
camProfile.videoBitRate = profile.videoBitRate;
|
||||
setCamcorderProfile(camProfile, recordAudio);
|
||||
|
||||
mMediaRecorder.setOrientationHint(getOutputRotation());
|
||||
|
||||
|
||||
@ -256,6 +256,9 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
|
||||
if (options.hasKey("quality")) {
|
||||
profile = RNCameraViewHelper.getCamcorderProfile(options.getInt("quality"));
|
||||
}
|
||||
if (options.hasKey("videoBitrate")) {
|
||||
profile.videoBitRate = options.getInt("videoBitrate");
|
||||
}
|
||||
|
||||
boolean recordAudio = true;
|
||||
if (options.hasKey("mute")) {
|
||||
|
||||
@ -482,6 +482,10 @@ Supported options:
|
||||
- `ios` Specifies capture settings suitable for CIF quality (352x288 pixel) video output.
|
||||
- `android` Not supported.
|
||||
|
||||
- `videoBitrate`. (int greater than 0) This option specifies a desired video bitrate. For example, 5\*1000\*1000 would be 5Mbps.
|
||||
- `ios` Not supported.
|
||||
- `android` Supported.
|
||||
|
||||
- `orientation` (string or number). Specifies the orientation that us used for recording the video. Possible values: `"portrait"`, `"portraitUpsideDown"`, `"landscapeLeft"` or `"landscapeRight"`.
|
||||
|
||||
If nothing is passed the device's highest camera quality will be used as default.
|
||||
|
||||
@ -72,6 +72,7 @@ type RecordingOptions = {
|
||||
codec?: string,
|
||||
mute?: boolean,
|
||||
path?: string,
|
||||
videoBitrate?: number,
|
||||
};
|
||||
|
||||
type EventCallbackArgumentsType = {
|
||||
@ -339,6 +340,13 @@ export default class Camera extends React.Component<PropsType, StateType> {
|
||||
}
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
if (options.videoBitrate && typeof options.videoBitrate !== 'number') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Video Bitrate should be a positive integer');
|
||||
}
|
||||
}
|
||||
|
||||
const { captureAudio } = this.props
|
||||
|
||||
if (!captureAudio) {
|
||||
|
||||
3
types/index.d.ts
vendored
3
types/index.d.ts
vendored
@ -266,6 +266,9 @@ interface RecordOptions {
|
||||
mirrorVideo?: boolean;
|
||||
path?: string;
|
||||
|
||||
/** Android only */
|
||||
videoBitrate?: number;
|
||||
|
||||
/** iOS only */
|
||||
codec?: keyof VideoCodec | VideoCodec[keyof VideoCodec];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user