diff --git a/camera/src/main/ets/cameramanagers/PhotoManager.ets b/camera/src/main/ets/cameramanagers/PhotoManager.ets index 42f0fc0f4364b0ae1b4b972f79972774c546e47d..b8a64d822efac6d86ed2385376a8b79688e56b89 100644 --- a/camera/src/main/ets/cameramanagers/PhotoManager.ets +++ b/camera/src/main/ets/cameramanagers/PhotoManager.ets @@ -72,18 +72,18 @@ export class PhotoManager implements OutputManager { try { const displayRatio = profile.size.width / profile.size.height; const profileWidth = profile.size.width; - const PhotoProfile = photoProfilesArray + const photoProfile = photoProfilesArray .sort((a, b) => Math.abs(a.size.width - profileWidth) - Math.abs(b.size.width - profileWidth)) .find(pf => { const pfDisplayRatio = pf.size.width / pf.size.height; return Math.abs(pfDisplayRatio - displayRatio) <= CameraConstant.PROFILE_DIFFERENCE && pf.format === camera.CameraFormat.CAMERA_FORMAT_JPEG; }); - if (!PhotoProfile) { + if (!photoProfile) { Logger.error(TAG_LOG, 'Failed to get photo profile'); return; } - cameraPhotoOutput = cameraManager?.createPhotoOutput(PhotoProfile); + cameraPhotoOutput = cameraManager?.createPhotoOutput(photoProfile); } catch (error) { Logger.error(TAG_LOG, `Failed to createPhotoOutput. error: ${JSON.stringify(error)}`); } @@ -227,6 +227,7 @@ export class PhotoManager implements OutputManager { // [Start set_color_space] // Set color space setColorSpaceBeforeCommitConfig(session: camera.PhotoSession, isHdr: boolean): void { + // The isHdr flag indicates whether HDR mode is enabled, with true representing the use of the DISPLAY_P3 color space. let colorSpace: colorSpaceManager.ColorSpace = isHdr ? colorSpaceManager.ColorSpace.DISPLAY_P3 : colorSpaceManager.ColorSpace.SRGB; let colorSpaces: Array = []; diff --git a/camera/src/main/ets/cameramanagers/VideoManager.ets b/camera/src/main/ets/cameramanagers/VideoManager.ets index c075098815b61ab8c9a993d2f932d04da5d9a155..cc36fb9def8790e5cbda671eaa2dc7a2e06c561f 100644 --- a/camera/src/main/ets/cameramanagers/VideoManager.ets +++ b/camera/src/main/ets/cameramanagers/VideoManager.ets @@ -253,9 +253,9 @@ export class VideoManager implements OutputManager { let options: photoAccessHelper.CreateOptions = { title: Date.now().toString() }; - let accessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(this.context); + let videoAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(this.context); try { - this.videoUri = await accessHelper.createAsset(photoAccessHelper.PhotoType.VIDEO, 'mp4', options); + this.videoUri = await videoAccessHelper.createAsset(photoAccessHelper.PhotoType.VIDEO, 'mp4', options); this.file = fileIo.openSync(this.videoUri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); } catch (exception) { Logger.error(TAG_LOG, `createAsset failed, code is ${exception.code}, message is ${exception.message}`); @@ -264,18 +264,19 @@ export class VideoManager implements OutputManager { // [Start av_profile] this.avProfile = { - audioBitrate: 48000, - audioChannels: 2, - audioCodec: media.CodecMimeType.AUDIO_AAC, - audioSampleRate: 48000, - fileFormat: media.ContainerFormatType.CFT_MPEG_4, - videoBitrate: 32000000, + audioBitrate: 48000, // Audio bitrate (unit: bps), which affects audio quality + audioChannels: 2, // Stereo two-channel recording + audioCodec: media.CodecMimeType.AUDIO_AAC, // The audio encoding format is AAC + audioSampleRate: 48000, // Audio sampling rate (unit: Hz), CD-quality sound + fileFormat: media.ContainerFormatType.CFT_MPEG_4, // Container Format Configuration + videoBitrate: 32000000, // Video bitrate (unit: bps) determines video clarity + // Dynamic Selection of Video Encoding Format videoCodec: (this.qualityLevel === QualityLevel.HIGHER && this.cameraPosition === 0) ? - media.CodecMimeType.VIDEO_HEVC : media.CodecMimeType.VIDEO_AVC, - videoFrameWidth: this.videoProfile?.size.width, - videoFrameHeight: this.videoProfile?.size.height, - videoFrameRate: this.cameraPosition === 0 ? 60 : 30, - } + media.CodecMimeType.VIDEO_HEVC : media.CodecMimeType.VIDEO_AVC, + videoFrameWidth: this.videoProfile?.size.width, // Obtain width from video configuration + videoFrameHeight: this.videoProfile?.size.height, // Obtain height from video configuration + videoFrameRate: this.cameraPosition === 0 ? 60 : 30, // Obtain rate from video configuration + }; // [End av_profile] // [Start av_config]