Skip to content
HuxerUIPublic

About

An audio and video development toolkit for HuxerUI with recording, real-time effects, timeline editing, and media export.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Lib-AVKit

Lib-AVKit is a C++20 audio and video post-processing library for HuxerUI. It provides an editable timeline, EntityX scene evaluation, GPU compositing, file codecs, vision analysis, and PAG animation. See the architecture for design and integration details.

Targets

Target Responsibility
AVKit::Core Projects, edit recipes, EntityX scene evaluation, tracking association, and the render plan contract.
AVKit::Media Lib-Media codec adapter, file readers, timeline sampling, thumbnails, waveforms, and MP4 output.
AVKit::FFmpeg FFmpeg software codec provider for the file profile.
AVKit::Bgfx Shared GPU compositor with platform shader binaries and SDK texture transfer.
AVKit::NCNN Cross-platform CPU provider for face, body, and hand landmarks and portrait segmentation.
AVKit::Render Timeline compositing, PAG animation and transitions, and texture transfer for preview and export.
HuxerUI::AVKit HuxerUI application hook and the combined AVKit library targets.

Core and the media orchestration use public HuxerUI and Lib-Media types. The file profile accepts SDR video in MP4, MOV, Matroska, WebM, MPEG-TS, and AVI. Supported codecs depend on the container and the available decoders. The workbench integrates file editing on macOS and Android. The recording workbench is available on macOS and Android. File profile Platform plan

AVKit-owned formats and resource manifests use version 1 during pre-release development. The workbench saves and opens the current v1 .avkit layout. Project persistence

Repository layout

Path Contents
include/huxerui/ Public cross-platform C++ headers.
src/ Shared project, ECS, analysis, media, and rendering code. render/bgfx/ contains the compositor and shared shader sources.
platform/ Platform texture bridges, graphics context setup, and packaging files.
cmake/ Target and dependency setup. AVKitBgfx.cmake selects the renderer, shader profile, and platform sources.
models/ Versioned model assets with checksums and upstream licenses.
examples/preview/ HuxerUI workbench in src/ and platform adapters in platform/.

In documentation and identifiers, use platform for platform adapters, capabilities, and storage. Use system for operating-system services and scheduling or when referring to an ECS system. Reserve native for terms such as JNI declarations and handles. Name a concrete type when it is known, such as a Metal texture or an FFmpeg frame.

Build

Use CMake 3.21 or newer and a HuxerUI SDK or source checkout selected through HUXERUI_HOME. The build uses the pinned Lib-Media Git revision by default. Set AVKIT_LIB_MEDIA_SOURCE_DIR to use a local checkout.

Each platform configures the same AVKit targets. FFmpeg and PAG use HuxerUI prebuilt SDKs. ncnn and bgfx are built from pinned sources. An application can link an individual AVKit target or HuxerUI::AVKit for the full set.

FFmpeg SDK

CMake selects a HuxerUI FFmpeg SDK package for the active target from the pinned release index, verifies its checksum and extracts it in the build directory. Set AVKIT_FFMPEG_SDK_ROOT to use a local package or a directory of packages extracted into their SDK target subdirectories. Configure one Apple architecture per build directory. Windows uses the Visual Studio x64 toolchain.

cmake -S . -B build/ffmpeg-debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build/ffmpeg-debug --config Debug --target avkit_ffmpeg_probe

In CLion select avkit_ffmpeg_probe as the run target. It opens the software H.264 and AAC encoders and, when given a movie path, decodes the first video frame and audio block. Windows stages the linked runtime DLLs next to the probe.

To build just the Core target after configuring the project, run the following commands.

cmake -S . -B build/core
cmake --build build/core --target avkit_core

PAG SDK

AVKit::Render uses the HuxerUI PAG SDK. CMake selects and verifies the pinned package for the active target. Set AVKIT_PAG_SDK_ROOT to use a local extracted package or a parent directory containing extracted SDKs grouped by target name.

The macOS and iOS adapters use Metal. Android shares OpenGL ES textures through EGL. Web uses WebGL 2 and initializes the browser runtime when the Emscripten module starts. Windows and Linux transfer the transition sides through pixels to accommodate the compositors' graphics APIs. Linux uses Fontconfig for system font fallback and requires its development headers.

On Android, CMake supplies the PAG native libraries and Gradle supplies the matching Java runtime JAR from the pinned PAG SDK release. The preview initializes it before starting native playback. For a local Android SDK override, set AVKIT_PAG_SDK_ROOT in the environment before invoking Gradle so both build steps select the same SDK.

Preview workbench

The workbench requires HuxerUI SDK 0.5.5 or a matching source checkout.

Capture on macOS and Android requires Lib-Camera and Lib-AudioCapture. Place the source checkouts next to Lib-AVKit or set AVKIT_LIB_CAMERA_SOURCE_DIR to the Camera checkout. The recording page supports JPEG photos, microphone audio, live voice processing, pause and resume, and saving a copy. AVKit's bgfx compositor applies the sticker and Camera records the result.

The macOS workbench supports file editing, export, PAG, and ncnn. File workflow

cmake -S examples/preview -B build/preview
cmake --build build/preview --target example_av_kit
open build/preview/example_av_kit.app

The Android workbench imports files in the file profile, plays and seeks the timeline, and exports BT.709 H.264/AAC MP4 through the system file picker. Lib-Media handles platform decoding and passes bgfx GLES composites to the MediaCodec AVC encoder surface. On a recoverable video encoder failure, export restarts from the beginning with FFmpeg and publishes the finalized MP4. Android export uses FFmpeg AAC-LC so the MP4 edit list carries exact priming and padding.

Android SDK packages contain static FFmpeg libraries for each ABI. For a local set of packages, extract them to target directories such as android-arm64-v8a and android-x86_64 under AVKIT_FFMPEG_SDK_ROOT. An individual package can be used for a single-ABI build.

huxerui run android --abi arm64-v8a

All supported platforms build the bgfx compositor. Cross builds compile the pinned shaderc for the host with the host C++ toolchain. Set AVKIT_BGFX_SHADERC to reuse an existing host executable built from the same revision. The compositor uses Metal on macOS and iOS, OpenGL ES 3 on Android, WebGL 2 on Web, and D3D11 for Windows builds hosted on Windows. Other Windows builds use Vulkan. Linux uses OpenGL for a current compatible GDK/EGL context and Vulkan for independent rendering. Linux builds use GTK, epoxy, EGL, X11, and XCB development headers. Render API

Open a managed TimelinePreviewSession to play, seek, and present an immutable project revision. The host applies each prepared frame and its selection geometry together. ExportProject executes the same render tree at the requested output size and can borrow the preview's renderer reservation for the duration of the export. Both accept the same scene configuration, including resource catalog, analysis adapter, and ECS module. Timeline renderer API

For independent processing, sample a TimelineSession or build a TimelineFrame from a RenderScene or a caller-authored RenderPlan. Use TimelineRenderer::OpenTimeline to bind timeline sampling to the GPU device, or call ImportTexture for a camera or other external GPU texture. Draw uploads retained CPU pixels as needed and produces a retained GPU result. Publish that image through a reusable PreviewTexture or transfer it to the selected encoder with EncoderFrame. Platform decoder textures that cannot be shared can be retried through FFmpeg at the same source timestamp. ECS API · Sampling API

InspectTimelineVisual imports movies and PNG or JPEG stills. ProjectEdit::InsertImage defaults to three seconds and accepts a duration override. The image remains a still in the project. OpenEditTemplate and CreateTemplateProject resolve a versioned recipe and produce a normal editable project. Project API · Template API

On macOS and Android, the preview example registers AVKit's compositor as a Camera frame processor and a duration-preserving voice effect as an AudioCapture PCM processor. Camera synchronizes audio and video and writes the MP4. The application owns permissions, device selection, preview layout, destination selection, and saving a composed still. Capture example

The ncnn provider accepts YuNet and MediaPipe body and hand model packs through the C++ factories. See body and hand tracking for the provider behavior.

Portrait background replacement uses MediaPipe Selfie Segmentation by default. Clips can select the optional PP-HumanSegV2-Lite pack independently. Model selection

About

An audio and video development toolkit for HuxerUI with recording, real-time effects, timeline editing, and media export.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages