From 1507e434346afe18d66e4e709859e68059dcd671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=8B=E8=83=BD=5F=E5=BC=A0=E5=BE=B7=E7=9B=9B?= Date: Tue, 9 Sep 2025 19:03:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=80=E4=BD=B3=E5=AE=9E?= =?UTF-8?q?=E8=B7=B5AI=E8=AF=86=E5=88=AB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/cameramanagers/PhotoManager.ets | 7 ++--- .../main/ets/cameramanagers/VideoManager.ets | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/camera/src/main/ets/cameramanagers/PhotoManager.ets b/camera/src/main/ets/cameramanagers/PhotoManager.ets index 967cfc8..d24bb09 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)}`); } @@ -222,6 +222,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 ff800b8..f4f7e51 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] -- Gitee