diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7491c1dbfcc9cd23436736aeb7b0de65b86b4754 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.videouseavtranscoder", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..94ac30860382b1f90f386f91837e55b794819712 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "VideoUseAVTranscoder" + } + ] +} diff --git a/AppScope/resources/base/media/background.png b/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AppScope/resources/base/media/background.png differ diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AppScope/resources/base/media/foreground.png differ diff --git a/AppScope/resources/base/media/layered_image.json b/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/README.en.md b/README.en.md index 50dfc169926650e40f5f473d7da95a49fb8add4f..541ef8de84897be095e4acb4784d1374b02edfb7 100644 --- a/README.en.md +++ b/README.en.md @@ -1,36 +1,66 @@ -# UseAVTranscoderVideo +## Use AVTranscoder to realize video transcoding (ArkTS) -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} +### Introduce -#### Software Architecture -Software architecture description +This example will explain the functions of AVTranscoder video transcoding to developers in a process +of "Start Transcoding-Pause Transcoding-Restore Transcoding-Transcoding Complete". -#### Installation +### Effect Preview -1. xxxx -2. xxxx -3. xxxx +| HomePage | TranscodingPage | TranscoderedPage | +|------------------------------------------------------------|---------------------------------------------------------------------|--------------------------------------------------------------------| +| | | | -#### Instructions +Instructions for use: +1. Open the application. The home page supports the parameter configuration required for video transcoding. +After selecting, click the start transcoding button to jump to the video transcoding page. +2. The video transcoding page can see the progress of video transcoding. Click the pause button, pause transcoding, +click the recovery button, and resume transcoding; click the cancel button, pop-up window reminds whether to cancel transcoding; +after transcoding is completed, click the completion button to jump to the transcoding completion page. +3. The transcoding completion page can watch the video after transcoding. Click the home button to return to the home page. -1. xxxx -2. xxxx -3. xxxx +### Engineering Catalogue -#### Contribution +``` +├──ets +│ ├──entryability +│ │ └──EntryAbility.ets +│ ├──pages +│ │ ├──index .ets // Home page +│ │ ├──TranscoderFinishPage.ets // Video transcoding completion page +│ │ ├──VideoTranscoderPage.ets // Video transcoding progress page +│ └──utils +│ └──AVTranscoderManager.ets // Video transcoding management +└──resources + └──rawfile + └──video_sample.mp4 // Transcoding video +``` -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request +### Concrete realization +1. Use [AVTranscoder](https://developer.huawei.com/consumer/doc/harmonyos-references/arkts-apis-media-avtranscoder) + Video transcoding management class, first through [createAVTranscoder()](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/arkts-apis-media-f#mediacreateavtranscoder12) + Build an AVTranscoder instance, then register the transcoding monitoring event, and finally call the relevant interface to realize the process of "start transcoding - pause transcoding - restore transcoding - transcoding completion". +2. By [AVTranscoder](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/arkts-apis-media-avtranscoder) + After transcoding, the output path is usually the path in the application sandbox. After the complete path needs to be stitched (such as files//app package name/output path), + Via [Video](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/ts-media-components-video) + Component to realize video playback, please refer to [How to get the BundleName of the current HAP](https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-package-structure-26) for the name of the application package -#### Gitee Feature +### Related Permissions + +Not involved + +### Dependency + +Not involved + +### Constraints and restrictions + +1.This example only supports running on standard systems and supports devices: Huawei mobile phones. + +2.HarmonyOS system: HarmonyOS 5.0.5 Release and above. + +3.DevEco Studio version: DevEco Studio 5.0.5 Release and above. + +4.HarmonyOS SDK version: HarmonyOS 5.0.5 Release SDK and above. -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index a52b59582468179fb9a3ca61002b87f3fd504cab..3695bee54494b56bf497faba7bb8415d35b22d61 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,63 @@ -# UseAVTranscoderVideo +## 使用AVTranscoder实现视频转码(ArkTS) -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例将以“开始转码-暂停转码-恢复转码-转码完成”的一次流程向开发者讲解AVTranscoder视频转码相关功能。 +### 效果预览 -#### 安装教程 +| 首页 | 视频转码页 | 转码完成页 | +|---------------------------------------------------------|------------------------------------------------------------------|-----------------------------------------------------------------| +| | | | -1. xxxx -2. xxxx -3. xxxx +使用说明: +1. 打开应用,首页支持选择视频转码所需的参数配置,选择完成后,点击开始转码按钮,跳转到视频转码页面。 +2. 视频转码页面可以看到视频转码的进度,点击暂停按钮,暂停转码,点击恢复按钮,恢复转码;点击取消按钮,弹窗提醒是否取消转码;转码完成后,点击完成按钮,跳转到转码完成页面。 +3. 转码完成页面可以观看转码完成后的视频,点击首页按钮,返回到首页。 -#### 使用说明 +### 工程目录 -1. xxxx -2. xxxx -3. xxxx -#### 参与贡献 +``` +├──ets +│ ├──entryability +│ │ └──EntryAbility.ets +│ ├──pages +│ │ ├──index .ets // 主页 +│ │ ├──TranscoderFinishPage.ets // 视频转码完成页面 +│ │ ├──VideoTranscoderPage.ets // 视频转码进度页面 +│ └──utils +│ └──AVTranscoderManager.ets // 视频转码管理类 +└──resources + └──rawfile + └──video_sample.mp4 // 转码视频 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 具体实现 +1. 使用[AVTranscoder](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/arkts-apis-media-avtranscoder) +视频转码管理类,先通过[createAVTranscoder()](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/arkts-apis-media-f#mediacreateavtranscoder12) +构建一个AVTranscoder实例,然后注册转码监听事件,最后调用相关接口实现“开始转码-暂停转码-恢复转码-转码完成”的流程。 +2. 通过[AVTranscoder](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/arkts-apis-media-avtranscoder) +转码后,输出路径通常为应用沙箱内的路径,需要拼接出完整路径(如:files//应用包名/输出路径)后, +通过[Video](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/ts-media-components-video) +组件实现视频播放,获取应用包名请参考[如何获取当前HAP的BundleName](https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs/faqs-package-structure-26) -#### 特技 +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机。 + +2.HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。 + +3.DevEco Studio版本:DevEco Studio 5.0.5 Release及以上。 + +4.HarmonyOS SDK版本:HarmonyOS 5.0.5 Release SDK及以上。 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3e9f2156122181c8269a1536cf2fdc01b4144532 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,56 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\admin\\.ohos\\config\\default_video-use-avtranscoder_LyzetE0A9DpHsiCjdnsBFuTUAYf3O717YkYnt0zcJdQ=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001AC5D479BAECCDF4F409593EC7452F75E41B72E756E7ED63171B35B739C4E025D75A4EC91B4D5F", + "profile": "C:\\Users\\admin\\.ohos\\config\\default_video-use-avtranscoder_LyzetE0A9DpHsiCjdnsBFuTUAYf3O717YkYnt0zcJdQ=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\admin\\.ohos\\config\\default_video-use-avtranscoder_LyzetE0A9DpHsiCjdnsBFuTUAYf3O717YkYnt0zcJdQ=.p12", + "storePassword": "0000001A59491211DC7EF2705001995E03F5A5B757ABFDF452C7F17A41BAB923F71B2EF7927D1ECDF781" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/entry/.gitignore b/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d089ce8235c50391b33890e682ed6bfba97f539c --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + let windowClass: window.Window = windowStage.getMainWindowSync(); // Get the main window of the application + // Settings window full screen + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen) + .then(() => { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }) + .catch((err: BusinessError) => { + console.error(`Failed to set the window layout to full-screen mode. Code is ${err.code}, message is ${err.message}`); + }); + + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8987bc49b44eb6bbc24a43a30e81594f668e0f9 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { media } from '@kit.MediaKit'; +import { VideoTranscoderPage } from './VideoTranscoderPage'; +import { TranscoderFinishPage } from './TranscoderFinishPage'; +import { avConfigCommon } from '../utils/AVTranscoderManager'; + +interface resolutionCommon { + name: Resource, + value: string +} + +// Resolution Array +const resolutionList: resolutionCommon[] = [ + { name: $r('app.string.standard_clearance'), value: '1280x720' }, + { name: $r('app.string.high_definition'), value: '1920x1080' }, + { name: $r('app.string.ultra_clear'), value: '3840x2160' }, +] + +// CodeRate Array +const codeRateList: string[] = ['2Mbps', '4Mbps', '6Mbps', '8Mbps', '16Mbps', '30Mbps', '50Mbps']; + +@Entry +@Component +struct Index { + @Provide('pathInfos') pathInfos: NavPathStack = new NavPathStack(); + @State resolution: string = '1920x1080'; + @State selectedIndex: number = 1; + @State videoFrameWidth: number = 0; + @State videoFrameHeight: number = 0; + controller: VideoController = new VideoController(); + + @Builder + myRouter(name: string) { + if (name === 'VideoTranscoderPage') { + VideoTranscoderPage(); + } else if (name === 'TranscoderFinishPage') { + TranscoderFinishPage(); + } + } + + @Builder + titleBar() { + Text($r('app.string.video_transcoder')) + .height('32vp') + .fontSize('26vp') + .fontWeight(700) + .textAlign(TextAlign.Start) + .margin('16vp') + } + + aboutToAppear(): void { + this.getVideoMetaData(); + } + onPageShow(): void { + this.controller.start() + } + + // Get video metadata + async getVideoMetaData() { + const TAG = 'MetadataDemo'; + const isSupport: boolean = canIUse('SystemCapability.Multimedia.Media.AVMetadataExtractor'); + if (isSupport) { + // Create an AVMetadataExtractor object + let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor(); + // Set up fdSrc + avMetadataExtractor.fdSrc = await getContext(this).resourceManager.getRawFd('video_sample.mp4'); + // Get metadata (callback mode) + avMetadataExtractor.fetchMetadata((error, metadata) => { + if (error) { + console.error(TAG, `fetchMetadata callback failed, err = ${JSON.stringify(error)}`); + return; + } + console.info(TAG, `fetchMetadata callback success, genre: ${JSON.stringify(metadata)}`); + // Initialization parameters + this.videoFrameWidth = Number(metadata.videoWidth); + this.videoFrameHeight = Number(metadata.videoHeight); + }) + } + } + + // Start the conversion. + onStart() { + // Judgment logic before conversion + const width: number = Number(this.resolution.split('x')[0]); + console.info('this.videoFrameWidth', this.videoFrameWidth, width); + if (this.videoFrameWidth < 3840 && width >= 3840) { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.showToastWarn4k'), + duration: 2000 + }) + } else if (this.videoFrameWidth < 1920 && width >= 1920) { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.showToastWarn1080'), + duration: 2000 + }) + } else if (this.videoFrameWidth < 720 && width >= 720) { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.showToastWarn720'), + duration: 2000 + }) + } else { + const codeRate: number = parseInt(codeRateList[this.selectedIndex].split('Mbps')[0]) * 1000000; + const params: avConfigCommon = { + resolution: this.resolution, + codeRate + } + this.pathInfos.pushPathByName('VideoTranscoderPage', params); + } + } + + build() { + Navigation(this.pathInfos) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + this.titleBar() + Column() { + Video({ + src: $rawfile('video_sample.mp4'), + controller: this.controller, + }) + .autoPlay(true) + .controls(false) + .loop(true) + } + .width('100%') + .height('292vp') + .flexShrink(0) + + Column() { + Row() { + Text($r('app.string.param_config')) + .textAlign(TextAlign.Start) + .fontWeight(400) + .fontSize('14vp') + } + .margin({ top: '20vp' }) + .padding({ top: '8vp', right: '12vp', bottom: '8vp', left: '12vp' }) + + Column() { + Row() { + Text($r('app.string.file_name')) + .fontColor('rgba(0, 0, 0, 0.9)') + .fontSize('16vp') + .fontWeight(500) + Text('video_sample.mp4') + .fontColor('rgba(0, 0, 0, 0.6)') + .fontSize('14vp') + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.SpaceBetween) + .commonStyle() + + Row() { + Text($r('app.string.resolution')) + .fontColor('rgba(0, 0, 0, 0.9)') + .fontSize('16vp') + .fontWeight(500) + Row() { + ForEach(resolutionList, (item: resolutionCommon, index: number) => { + Text(item.name) + .margin({ left: '16vp' }) + .padding({ top: '4.5vp', right: '12vp', bottom: '4.5vp', left: '12vp' }) + .backgroundColor(item.value === this.resolution ? '#0A59F7' : 'rgba(0, 0, 0, 0.05)') + .textAlign(TextAlign.Center) + .borderRadius('14vp') + .fontColor(item.value === this.resolution ? Color.White : 'rgba(0, 0, 0, 0.6)') + .onClick(() => { + this.resolution = item.value + }) + }, (item: resolutionCommon, index: number) => String(index)) + } + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.SpaceBetween) + .commonStyle() + + Row() { + Text($r('app.string.code_rate')) + .fontColor('rgba(0, 0, 0, 0.9)') + .fontSize('16vp') + .fontWeight(500) + + Row() { + Text(String(codeRateList[this.selectedIndex])) + .fontColor('rgba(0, 0, 0, 0.9)') + .fontSize('14vp') + Text() { + SymbolSpan($r('sys.symbol.arrowtriangle_down_fill')) + .fontSize('14vp') + } + .margin({ left: '9vp' }) + } + .onClick(() => { + this.getUIContext().showTextPickerDialog({ + range: codeRateList, + selected: this.selectedIndex, + defaultPickerItemHeight: 40, + onAccept: (value: TextPickerResult) => { + this.selectedIndex = Number(value.index); + } + }); + }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.SpaceBetween) + .commonStyle() + .border({ + width: '0vp' + }) + } + .width('100%') + .backgroundColor(Color.White) + .borderRadius('16vp') + .padding({ top: '4vp', right: '12vp', bottom: '4vp', left: '12vp' }) + } + .padding({ left: '16vp', right: '16vp' }) + .flexGrow(1) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + Column() { + Button($r('app.string.start_transfer'), { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .width('100%') + .backgroundColor('#0A59F7') + .onClick(() => { + this.onStart() + }) + } + .width('100%') + .padding('16vp') + .flexShrink(0) + } + .width('100%') + .height('100%') + } + .padding({ top: '36vp', bottom: '28vp' }) + .navDestination(this.myRouter) + .hideTitleBar(true) + .hideToolBar(true) + .backgroundColor('#F1F3F5') + } + + @Styles + commonStyle() { + .width('100%') + .padding({ + top: '13vp', + right: '0vp', + bottom: '13vp', + left: '0vp' + }) + .border({ + width: { bottom: '0.5vp' }, + color: 'rgba(0, 0, 0, 0.2)' + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/TranscoderFinishPage.ets b/entry/src/main/ets/pages/TranscoderFinishPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..e86707edcdb4994dc8d357fb7336512ec0dd92a8 --- /dev/null +++ b/entry/src/main/ets/pages/TranscoderFinishPage.ets @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { bundleManager } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { outputPathCommon } from '../utils/AVTranscoderManager' + +@Component +export struct TranscoderFinishPage { + @Consume('pathInfos') pathInfos: NavPathStack; + @State outputFilePath: string = ''; + @State filePath: string = ''; + + getParamsPrint() { + const params: outputPathCommon = JSON.parse(JSON.stringify(this.pathInfos.getParamByName('TranscoderFinishPage')[0])); + console.info('params', params); + this.outputFilePath = params.outputFilePath; + const bundleName: string = this.getBundleName(); + this.filePath = 'file://' + bundleName + params.outputFilePath; + } + + // Get the current HAP package name + getBundleName(): string { + let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + let bundleName: string = ''; + try { + bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { + bundleName = data.name; + hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); + }); + } catch (err) { + let message = (err as BusinessError).message; + hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); + } + return bundleName; + } + build() { + NavDestination() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + Column() { + Video({ src: this.filePath }) + .autoPlay(true) + .controls(false) + .loop(true) + } + .width('100%') + .height('292vp') + .flexShrink(0) + + Column() { + Row() { + Text() { + SymbolSpan($r('sys.symbol.checkmark_circle')) + .fontSize('22vp') + .fontColor(['#64BB5C']) + } + Text($r('app.string.convert_success')) + .fontSize('14vp') + .fontColor('rgba(0, 0, 0, 0.9)') + .margin({ left: '9vp' }) + } + .justifyContent(FlexAlign.Center) + .padding({ top: '12.5vp', bottom: '12.5vp' }) + .width('100%') + .backgroundColor(Color.White) + .borderRadius('12vp') + + Row() { + Text(`Storage Path:${this.outputFilePath}`) + .fontSize('12vp') + .fontColor('rgba(0, 0, 0, 0.6)') + .maxLines(2) + } + .width('100%') + .margin({ top: '12vp' }) + } + .margin({ top: '8vp' }) + .padding('16vp') + .flexGrow(1) + + Column() { + Button($r('app.string.button_back'), { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .width('100%') + .onClick(() => { + this.pathInfos.pop(); + }) + } + .width('100%') + .padding('16vp') + .flexShrink(0) + } + } + .title($r('app.string.transcoder_result')) + .height('100%') + .width('100%') + .backgroundColor('#F1F3F5') + .onShown(() => { + this.getParamsPrint(); + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/VideoTranscoderPage.ets b/entry/src/main/ets/pages/VideoTranscoderPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..940640ca45885b6167778eee0bf7cc60d9976e90 --- /dev/null +++ b/entry/src/main/ets/pages/VideoTranscoderPage.ets @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { common } from '@kit.AbilityKit'; +import { AVTranscoderManager, outputPathCommon } from '../utils/AVTranscoderManager'; + +@CustomDialog +struct MyCustomDialog { + controller: CustomDialogController; + cancel: () => void = () => {}; + confirm: () => void = () => {}; + + build() { + Column() { + Text($r('app.string.text_cancel')) + .textAlign(TextAlign.Center) + .fontSize('16vp') + .fontColor('rgba(0, 0, 0, 0.9)') + .lineHeight('21vp') + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Button($r('app.string.button_cancel'), { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .flexGrow(1) + .backgroundColor(Color.Transparent) + .fontColor('#0A59F7') + .fontSize('16vp') + .fontWeight(500) + .onClick(() => { + this.cancel() + }) + Divider() + .vertical(true) + .strokeWidth('0.5vp') + .height(24) + .color('rgba(0, 0, 0, 0.05)') + .margin({ left: 4, right: 4 }) + Button($r('app.string.button_confirm'), { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .flexGrow(1) + .backgroundColor(Color.Transparent) + .fontColor('#0A59F7') + .fontSize('16vp') + .fontWeight(500) + .onClick(() => { + this.confirm() + }) + } + .height('40vp') + .margin({ top: '8vp' }) + } + .width('328vp') + .padding('24vp') + .borderRadius('32vp') + .backgroundColor(Color.White) + } +} + +@Component +export struct VideoTranscoderPage { + @Consume('pathInfos') pathInfos: NavPathStack; + private context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; + @State avTranscoder: AVTranscoderManager = new AVTranscoderManager(this.context); // Get the transcoding function management class + @State isPause: boolean = false; + @State isFinish: boolean = false; + @State progress: number = 0; + private progressColors: LinearGradient = new LinearGradient([{ color: "#f7cd00", offset: 0 }, { color: "#f99b11", offset: 1 }]); + + getParamsPrint() { + this.context.eventHub.on('myEvent', this.eventFunc); + const params: string = JSON.stringify(this.pathInfos.getParamByName('VideoTranscoderPage')[0]); + this.avTranscoder.setAVConfig(JSON.parse(params)); + this.avTranscoder.startTranscoderProcess(); + } + + // Conversion progress monitoring event + eventFunc = (progress: number) => { + this.progress = progress; + this.isFinish = progress === 100; + } + + dialogController: CustomDialogController = new CustomDialogController({ + builder: MyCustomDialog({ + cancel: ()=> { this.onCancel() }, + confirm: ()=> { this.onConfirm() } + }), + alignment: DialogAlignment.Center, + customStyle: true + }) + + // Close the pop-up window + onCancel() { + this.dialogController.close(); + } + + // Confirm the cancellation of transcoding + onConfirm() { + this.avTranscoder.releaseTranscoderProcess(); + this.pathInfos.pop(); + this.dialogController.close(); + } + build() { + NavDestination() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + Column() { + Stack() { + Progress({ value: 0, total: 100, type: ProgressType.Ring }) + .value(this.progress) + .width('248vp') + .height('248vp') + .backgroundColor(Color.White) + .color(this.progressColors) + .style({ strokeWidth: 20 }) + Column() { + Row() { + Text(`${this.progress}`) + .fontSize('60vp') + .lineHeight('60vp') + .fontColor('rgba(0, 0, 0, 0.9)') + .fontWeight(700) + Text('%') + .fontSize('16vp') + .fontColor('rgba(0, 0, 0, 0.6)') + .lineHeight('60vp') + } + .alignItems(VerticalAlign.Bottom) + + Text($r('app.string.current_process')) + .fontSize('14vp') + .fontColor('rgba(0, 0, 0, 0.6)') + } + + } + .margin({ top: '56vp' }) + + Text($r('app.string.high_speed_processing')) + .margin({ top: '24vp' }) + .fontSize('20vp') + + Text($r('app.string.tip')) + .width('80%') + .textAlign(TextAlign.Center) + .fontColor('#595959') + .fontSize('16vp') + .margin({ top: '24vp' }) + } + .width('100%') + .flexGrow(1) + .alignItems(HorizontalAlign.Center) + + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + Button(this.isPause ? $r('app.string.button_continue') : $r('app.string.button_pause'), + { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .flexGrow(1) + .height('40vp') + .onClick(() => { + if (this.isFinish) { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.showToastWarnPause'), + duration: 2000 + }) + return + } + if (this.isPause) { + // Resume to convert + this.avTranscoder.resumeTranscoderProcess() + this.isPause = false + } else { + // Suspend the conversion + this.avTranscoder.pauseTranscoderProcess() + this.isPause = true + } + }) + + + Button(this.isFinish ? $r('app.string.button_finish') : $r('app.string.button_cancel'), + { buttonStyle: ButtonStyleMode.EMPHASIZED, role: ButtonRole.NORMAL }) + .flexGrow(1) + .height('40vp') + .margin({ left: '12vp' }) + .onClick(() => { + if (this.isFinish) { + // Conversion Complete + const params: outputPathCommon = { + outputFilePath: this.avTranscoder.outputFilePath + } + this.pathInfos.replacePathByName('TranscoderFinishPage', params); + } else { + // Cancel the conversion + this.dialogController.open(); + } + }) + } + .width('100%') + .padding('16vp') + .flexShrink(0) + } + } + .title($r('app.string.transcoder_progress')) + .height('100%') + .width('100%') + .backgroundColor('#F1F3F5') + .onShown(() => { + this.getParamsPrint(); + }) + .onHidden(() => { + this.context.eventHub.off('myEvent', this.eventFunc); + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/AVTranscoderManager.ets b/entry/src/main/ets/utils/AVTranscoderManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..8564a99cb4f6f218d7b828164226c5377a9a1b73 --- /dev/null +++ b/entry/src/main/ets/utils/AVTranscoderManager.ets @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { media } from '@kit.MediaKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { fileIo as fs} from '@kit.CoreFileKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export interface avConfigCommon { + resolution: string, + codeRate: number +} + +export interface outputPathCommon { + outputFilePath: string +} + +export class AVTranscoderManager { + private avTranscoder: media.AVTranscoder | undefined = undefined; + private context: Context | undefined; + private currentProgress: number = 0; + private isSupport: boolean = canIUse('SystemCapability.Multimedia.Media.AVTranscoder'); + outputFilePath: string = ''; + + constructor(context: Context | undefined) { + if (context != undefined) { + this.context = context; + } + } + + private avConfig: media.AVTranscoderConfig = { + fileFormat: media.ContainerFormatType.CFT_MPEG_4, // The encapsulation format of the output video currently only supports MP4. + videoBitrate: 200000, // Video code rate. + videoCodec: media.CodecMimeType.VIDEO_AVC, // Video encoding format + videoFrameWidth: 1920, // Resolution width [240-3840] + videoFrameHeight: 1080, // High resolution [240-2160] + } + + // Set conversion parameters + setAVConfig(params: avConfigCommon) { + const resolutionList: string[] = params.resolution.split('x'); + this.avConfig.videoFrameWidth = Number(resolutionList[0]); + this.avConfig.videoFrameHeight = Number(resolutionList[1]); + this.avConfig.videoBitrate = params.codeRate; + } + + // Register avTranscoder callback function + setAVTranscoderCallback() { + if (this.avTranscoder) { + // Transcoding to complete the callback function + this.avTranscoder.on('complete', async () => { + hilog.info(0x0000, 'testTag', 'AVTranscoder is completed'); + await this.releaseTranscoderProcess(); + }) + // Error report callback function + this.avTranscoder.on('error', (err: BusinessError) => { + hilog.error(0x0000, 'testTag', `AVTranscoder failed, code is ${err.code}, message is ${err.message}`); + }) + // Progress report callback function + this.avTranscoder.on('progressUpdate', (progress: number) => { + hilog.info(0x0000, 'testTag', `AVTranscoder progressUpdate = ${progress}`); + this.currentProgress = progress; + this.context?.eventHub.emit('myEvent', progress); + }) + } + } + + // Start the process for transcoding + async startTranscoderProcess() { + if (this.isSupport) { + if (this.avTranscoder) { + await this.avTranscoder.release(); + this.avTranscoder = undefined; + }; + // 1. Create a transcoding instance. + this.avTranscoder = await media.createAVTranscoder(); + this.setAVTranscoderCallback(); + // 2. Get the transcoding source file fd and the target file fd to avTranscoder; refer to the FilePicker document. + if (this.context) { + try { + // To obtain the input file fd, video_sample.mp4 is a provisioning resource in the rawfile directory, + // which needs to be replaced by the developer according to the actual situation. + let fileDescriptor = await this.context.resourceManager.getRawFd('video_sample.mp4'); + this.avTranscoder.fdSrc = fileDescriptor; + } catch (error) { + hilog.error(0x0000, 'testTag', 'Failed to get the file descriptor, please check the resource and path.'); + } + let outputFilePath = this.context.filesDir + '/output.mp4'; + let file = fs.openSync(outputFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + this.avTranscoder.fdDst = file.fd; + this.outputFilePath = outputFilePath; + this.currentProgress = 0; + } + // 3. Configure transcoding parameters to complete the preparation. + await this.avTranscoder.prepare(this.avConfig); + // 4. Start transcoding. + await this.avTranscoder.start(); + } + } + + // Pause the process for transcoding. + async pauseTranscoderProcess() { + if (this.isSupport && this.avTranscoder) { + // Call pause only after the start returns. + await this.avTranscoder.pause(); + } + } + + // Restore the corresponding transcoding process. + async resumeTranscoderProcess() { + if (this.isSupport && this.avTranscoder) { + // It is reasonable to call resume only after the call is returned. + await this.avTranscoder.resume(); + } + } + + // Release the transcoding process. + async releaseTranscoderProcess() { + if (this.isSupport && this.avTranscoder) { + // 1. Release the transcoding instance. + await this.avTranscoder.release(); + this.avTranscoder = undefined; + // 2. Turn off the transcoding target file fd. + fs.closeSync(this.avTranscoder!.fdDst); + } + } + + // Get the current progress + getCurrentProgress(): number { + hilog.info(0x0000, 'testTag', `getCurrentProgress = ${this.currentProgress}`); + return this.currentProgress; + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..200f1f31770430d82f88a6847b37a4d4538ab021 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "视频转码" + }, + { + "name": "start_transfer", + "value": "开始转换" + }, + { + "name": "button_pause", + "value": "暂停" + }, + { + "name": "button_confirm", + "value": "确定" + }, + { + "name": "button_continue", + "value": "继续" + }, + { + "name": "button_cancel", + "value": "取消" + }, + { + "name": "button_finish", + "value": "完成" + }, + { + "name": "button_back", + "value": "首页" + }, + { + "name": "param_config", + "value": "参数配置" + }, + { + "name": "file_name", + "value": "文件名" + }, + { + "name": "resolution", + "value": "分辨率" + }, + { + "name": "standard_clearance", + "value": "720P" + }, + { + "name": "high_definition", + "value": "1080P" + }, + { + "name": "ultra_clear", + "value": "4K" + }, + { + "name": "code_rate", + "value": "码率" + }, + { + "name": "frame_rate", + "value": "帧率" + }, + { + "name": "text_cancel", + "value": "确定取消转码吗?" + }, + { + "name": "high_speed_processing", + "value": "极速处理中..." + }, + { + "name": "original", + "value": "原始" + }, + { + "name": "tip", + "value": "任务正在进行中,请勿熄屏或退出APP,否则可能会导致失效" + }, + { + "name": "convert_success", + "value": "转换成功" + }, + { + "name": "storage_path", + "value": "存储路径" + }, + { + "name": "video_transcoder", + "value": "视频转码" + }, + { + "name": "transcoder_progress", + "value": "转码进度" + }, + { + "name": "transcoder_result", + "value": "转码结果" + }, + { + "name": "current_process", + "value": "当前转换进度" + }, + { + "name": "showToastWarn4k", + "value": "预置视频不支持转换为更高分辨率。请切换到4K以下的分辨率。" + }, + { + "name": "showToastWarn1080", + "value": "预置视频不支持转换为更高分辨率。请切换到1080P以下的分辨率。" + }, + { + "name": "showToastWarn720", + "value": "预置视频不支持转换为更高分辨率。请切换到720P以下的分辨率。" + }, + { + "name": "showToastWarnPause", + "value": "转换已完成,请点击完成按钮。" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/dark/element/color.json b/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..70339e350a9c66dba21cbccab2a9fe356bedc211 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "videoTranscoder" + }, + { + "name": "start_transfer", + "value": "Start the conversion" + }, + { + "name": "button_pause", + "value": "Suspend" + }, + { + "name": "button_confirm", + "value": "Certain" + }, + { + "name": "button_continue", + "value": "Continue" + }, + { + "name": "button_cancel", + "value": "Cancel" + }, + { + "name": "button_finish", + "value": "Accomplish" + }, + { + "name": "button_back", + "value": "Home page" + }, + { + "name": "param_config", + "value": "Parameter configuration" + }, + { + "name": "file_name", + "value": "File name" + }, + { + "name": "resolution", + "value": "Resolution" + }, + { + "name": "standard_clearance", + "value": "720P" + }, + { + "name": "high_definition", + "value": "1080P" + }, + { + "name": "ultra_clear", + "value": "4K" + }, + { + "name": "code_rate", + "value": "Bit rate" + }, + { + "name": "frame_rate", + "value": "Frame rate" + }, + { + "name": "text_cancel", + "value": "Are you sure you want to cancel the transcoding?" + }, + { + "name": "high_speed_processing", + "value": "In the process of speed..." + }, + { + "name": "original", + "value": "Original" + }, + { + "name": "tip", + "value": "The task is in progress. Please do not turn off the screen or exit the APP, otherwise it may fail." + }, + { + "name": "convert_success", + "value": "Convert to work" + }, + { + "name": "storage_path", + "value": "Storage path" + }, + { + "name": "video_transcoder", + "value": "Video Transcoder" + }, + { + "name": "transcoder_progress", + "value": "Transcoder Progress" + }, + { + "name": "transcoder_result", + "value": "Transcoder Result" + }, + { + "name": "current_process", + "value": "Current Progress" + }, + { + "name": "showToastWarn4k", + "value": "The preset video does not support conversion to a higher resolution. Please switch to a resolution below 4K." + }, + { + "name": "showToastWarn1080", + "value": "The preset video does not support conversion to a higher resolution. Please switch to a resolution below 1080." + }, + { + "name": "showToastWarn720", + "value": "The preset video does not support conversion to a higher resolution. Please switch to a resolution below 720." + }, + { + "name": "showToastWarnPause", + "value": "The conversion has been completed. Please click the completion button." + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/video_sample.mp4 b/entry/src/main/resources/rawfile/video_sample.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b529170de5433cb2ec4a9d092d923ffd9e3583a4 Binary files /dev/null and b/entry/src/main/resources/rawfile/video_sample.mp4 differ diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..200f1f31770430d82f88a6847b37a4d4538ab021 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "视频转码" + }, + { + "name": "start_transfer", + "value": "开始转换" + }, + { + "name": "button_pause", + "value": "暂停" + }, + { + "name": "button_confirm", + "value": "确定" + }, + { + "name": "button_continue", + "value": "继续" + }, + { + "name": "button_cancel", + "value": "取消" + }, + { + "name": "button_finish", + "value": "完成" + }, + { + "name": "button_back", + "value": "首页" + }, + { + "name": "param_config", + "value": "参数配置" + }, + { + "name": "file_name", + "value": "文件名" + }, + { + "name": "resolution", + "value": "分辨率" + }, + { + "name": "standard_clearance", + "value": "720P" + }, + { + "name": "high_definition", + "value": "1080P" + }, + { + "name": "ultra_clear", + "value": "4K" + }, + { + "name": "code_rate", + "value": "码率" + }, + { + "name": "frame_rate", + "value": "帧率" + }, + { + "name": "text_cancel", + "value": "确定取消转码吗?" + }, + { + "name": "high_speed_processing", + "value": "极速处理中..." + }, + { + "name": "original", + "value": "原始" + }, + { + "name": "tip", + "value": "任务正在进行中,请勿熄屏或退出APP,否则可能会导致失效" + }, + { + "name": "convert_success", + "value": "转换成功" + }, + { + "name": "storage_path", + "value": "存储路径" + }, + { + "name": "video_transcoder", + "value": "视频转码" + }, + { + "name": "transcoder_progress", + "value": "转码进度" + }, + { + "name": "transcoder_result", + "value": "转码结果" + }, + { + "name": "current_process", + "value": "当前转换进度" + }, + { + "name": "showToastWarn4k", + "value": "预置视频不支持转换为更高分辨率。请切换到4K以下的分辨率。" + }, + { + "name": "showToastWarn1080", + "value": "预置视频不支持转换为更高分辨率。请切换到1080P以下的分辨率。" + }, + { + "name": "showToastWarn720", + "value": "预置视频不支持转换为更高分辨率。请切换到720P以下的分辨率。" + }, + { + "name": "showToastWarnPause", + "value": "转换已完成,请点击完成按钮。" + } + ] +} \ No newline at end of file diff --git a/entry/src/test/List.test.ets b/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/entry/src/test/LocalUnit.test.ets b/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c2f6d1bc9cb330eeb990573aa7e74cbccfb64b61 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/screenshots/devices/ScreenRecord_20250701152349933.mp4 b/screenshots/devices/ScreenRecord_20250701152349933.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..de614ddff8481621324a0c3f1eb47ca395575a2d Binary files /dev/null and b/screenshots/devices/ScreenRecord_20250701152349933.mp4 differ diff --git a/screenshots/devices/dialog.png b/screenshots/devices/dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..f392b0b89aa571baffd5f026c9ae92aa6bb10b53 Binary files /dev/null and b/screenshots/devices/dialog.png differ diff --git a/screenshots/devices/home.png b/screenshots/devices/home.png new file mode 100644 index 0000000000000000000000000000000000000000..c2124ef260c8be04fc2ff0212d95ef9ff07bf5e3 Binary files /dev/null and b/screenshots/devices/home.png differ diff --git a/screenshots/devices/home_en.png b/screenshots/devices/home_en.png new file mode 100644 index 0000000000000000000000000000000000000000..5ad3efad6d9b47f2b8348e38420e6986ed916176 Binary files /dev/null and b/screenshots/devices/home_en.png differ diff --git a/screenshots/devices/transcodered.png b/screenshots/devices/transcodered.png new file mode 100644 index 0000000000000000000000000000000000000000..50d393ca929dbf48e8851b42f1504312c83ad513 Binary files /dev/null and b/screenshots/devices/transcodered.png differ diff --git a/screenshots/devices/transcodered_en.png b/screenshots/devices/transcodered_en.png new file mode 100644 index 0000000000000000000000000000000000000000..834e2550f230f7d3d4b4d777ca7bcde78645b0df Binary files /dev/null and b/screenshots/devices/transcodered_en.png differ diff --git a/screenshots/devices/transcodering.png b/screenshots/devices/transcodering.png new file mode 100644 index 0000000000000000000000000000000000000000..b0915cf5287120d38e0389f79506627697eff0e7 Binary files /dev/null and b/screenshots/devices/transcodering.png differ diff --git a/screenshots/devices/transcodering_en.png b/screenshots/devices/transcodering_en.png new file mode 100644 index 0000000000000000000000000000000000000000..64617a50f7033c34d7edebb7092f5afdf27ef46b Binary files /dev/null and b/screenshots/devices/transcodering_en.png differ