# AVMediaEngine **Repository Path**: zhangkede/avmedia-engine ## Basic Information - **Project Name**: AVMediaEngine - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-22 - **Last Updated**: 2026-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AVMediaEngine 一个完整的 **Android 音视频开发学习工程**,包含 15 个可运行示例 + 详细学习文档,覆盖从基础播放到 AI 美颜的完整技术栈。 ## 项目结构 | 模块 | 说明 | |------|------| | `app/androidApp` | Android 应用(15 个音视频示例 + 美颜相机 UI) | | `beauty-engine` | 美颜引擎 SDK(独立 Android Library,可复用/发布 AAR) | | `app/shared` | KMP 共享代码 | | `core` | 跨平台核心代码 | | `server` | Ktor 服务端 | | `docs/android-av-guide.md` | 详细学习文档(20 章) | ## 音视频示例(15 步渐进) | Step | 功能 | 核心技术 | |------|------|---------| | 1 | 音频播放 | MediaPlayer | | 2 | 视频播放 | Media3 / ExoPlayer | | 3 | 音频录制 | MediaRecorder | | 4 | 视频录制 | CameraX | | 5 | 视频处理 | MediaMetadataRetriever / MediaExtractor | | 6 | 底层 PCM 音频 | AudioRecord / AudioTrack | | 7 | 音视频分离/封装 | MediaExtractor / MediaCodec / MediaMuxer | | 8 | 屏幕录制 | MediaProjection | | 9 | 系统媒体控制 | MediaSession | | 10 | FFmpeg 剪辑/转码 | FFmpeg Kit | | 11 | OpenGL ES 滤镜 | GLSL 着色器 | | 12 | 网络流播放 | HLS / DASH | | 13 | RTMP 推流 | RootEncoder | | 14 | WebRTC 通话 | WebRTC | | 15 | **美颜相机** | CameraX + OpenGL + ML Kit | ## 美颜引擎(beauty-engine) 独立的美颜 SDK,支持: - **美颜**:磨皮 / 美白 / 大眼 / 瘦脸 / 口红 / 腮红 - **滤镜**:原图 / 自然 / 暖阳 / 冷调 - **贴纸**:4 种素材(王冠 / 星星 / 爱心 / 花环) - **AI 检测**:ML Kit 人脸关键点(6 点)+ FaceMesh(468 点) - **拍照**:glReadPixels 保存 - **视频录制**:MediaCodec 硬编码 + 音频同步 - **预设**:原图 / 自然 / 精致 / 网红 - **摄像头**:前后切换 核心类: - `BeautyCameraSDK`:门面,统一 API - `BeautyRenderer`:GL 渲染核心 - `FaceLandmarkDetector` / `FaceMeshLandmarkDetector`:AI 检测 - `VideoBeautyRecorder`:音视频录制 - `BeautyRtmpStreamer`:美颜推流(RTMP) ## 快速开始 ```bash # 构建 Android APK ./gradlew :app:androidApp:assembleDebug # 构建美颜引擎 AAR ./gradlew :beauty-engine:assembleDebug # 发布美颜引擎到本地 Maven 仓库(build/repo) ./gradlew :beauty-engine:publishReleasePublicationToLocalRepository ``` 发布后,其他项目可这样引用美颜引擎: ```kotlin repositories { maven { url = uri("file:///path/to/build/repo") } } dependencies { implementation("com.pragmatic:beauty-engine:1.0.0") } ``` 详细学习指南见 [docs/android-av-guide.md](./docs/android-av-guide.md)。 --- ## 原始 KMP 项目说明 This is a Kotlin Multiplatform project targeting Android, iOS, Web, Desktop (JVM), Server. * [/app/iosApp](./app/iosApp/iosApp) contains an iOS application. Even if you’re sharing your UI with Compose Multiplatform, you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project. * [/app/shared](./app/shared/src) is for code that will be shared across your Compose Multiplatform applications. It contains several subfolders: - [commonMain](./app/shared/src/commonMain/kotlin) is for code that’s common for all targets. - Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, the [iosMain](./app/shared/src/iosMain/kotlin) folder would be the right place for such calls. Similarly, if you want to edit the Desktop (JVM) specific part, the [jvmMain](./app/shared/src/jvmMain/kotlin) folder is the appropriate location. * [/core](./core/src) is for the code that will be shared between all targets in the project. The most important subfolder is [commonMain](./core/src/commonMain/kotlin). If preferred, you can add code to the platform-specific folders here too. * [/server](./server/src/main/kotlin) is for the Ktor server application. ### Running the apps Use the run configurations provided by the run widget in your IDE's toolbar. You can also use these commands and options: - Android app: `./gradlew :app:androidApp:assembleDebug` - Desktop app: - Hot reload: `./gradlew :app:desktopApp:hotRun --auto` - Standard run: `./gradlew :app:desktopApp:run` - Server: `./gradlew :server:run` - Web app: - Wasm target (faster, modern browsers): `./gradlew :app:webApp:wasmJsBrowserDevelopmentRun` - JS target (slower, supports older browsers): `./gradlew :app:webApp:jsBrowserDevelopmentRun` - iOS app: open the [/app/iosApp](./app/iosApp) directory in Xcode and run it from there. ### Running tests Use the run button in your IDE's editor gutter, or run tests using Gradle tasks: - Android tests: `./gradlew :app:shared:testAndroidHostTest` - Desktop tests: `./gradlew :app:shared:jvmTest` - Server tests: `./gradlew :server:test` - Web tests: - Wasm target: `./gradlew :app:shared:wasmJsTest` - JS target: `./gradlew :app:shared:jsTest` - iOS tests: `./gradlew :app:shared:iosSimulatorArm64Test` --- Learn more about [Kotlin Multiplatform](https://www.jetbrains.com.cn/en-us/help/kotlin-multiplatform-dev/get-started.html), [Compose Multiplatform](https://kotlinlang.org/compose-multiplatform/), [Kotlin/Wasm](https://kotl.in/wasm/)… We would appreciate your feedback on Compose/Web and Kotlin/Wasm in the public Slack channel [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web). If you face any issues, please report them on [YouTrack](https://youtrack.jetbrains.com/newIssue?project=CMP).