diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..c3cfc2a6f608440a0d3a0ad086cb8599cc763564 --- /dev/null +++ b/README.en.md @@ -0,0 +1,89 @@ +# Image-to-Video Synthesis + +## Overview +This sample demonstrates how to leverage AVCodec capabilities to implement image-to-video synthesis in buffer mode. It decodes images into PixelMap objects via ImageSource, transfers them to the native layer, and invokes the encoder and muxer to complete the entire workflow of image decoding, video encoding, and media multiplexing. + +## Preview + + +## How to Use +1. Go to the home page and tap Select images and synthesize video to launch a modal for selecting images. +2. Select at least two images and confirm. The system will start video synthesis and display a loading dialog. +3. Once video synthesis is complete, the loading dialog disappears, and the video starts playing automatically. + +## Project Directory + +``` +├──entry/src/main/cpp // Native layer +│ ├──capbilities // Capability APIs and implementation +│ │ ├──include // Capability APIs +│ │ ├──Muxer.cpp // Muxer implementation +│ │ └──VideoEncoder.cpp // Video encoder implementation +│ ├──common // Common modules +│ │ ├──dfx // Logs +│ │ ├──SampleCallback.cpp // Codec callback implementation +│ │ ├──SampleCallback.h // Codec callback definition +│ │ └──SampleInfo.h // Common classes for functionality implementation +│ ├──transcoding // APIs and implementation for video synthesis +│ │ ├──include // Capability APIs +│ │ ├──Transcoding.cpp // Call logic implementation for video synthesis +│ │ └──TranscodingNative.cpp // Entry for video synthesis +│ ├──types // APIs exposed by the native layer +│ │ ├──index.d.ts // API definition +│ │ └──oh-package.json5 // Configuration file +│ └──CMakeLists.txt // Compilation entry +├──ets // UI layer +│ ├──common // Common modules +│ │ ├──utils // Common utilities +│ │ │ ├──TimeUtils.ets // Time retrieval utility +│ │ └──CommonConstants.ets // Common constants +│ ├──entryability // Application entry +│ │ └──EntryAbility.ets +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets +│ ├──model +│ │ └──VideoDataModel.ets // Parameter data class +│ └──pages // Pages contained in the EntryAbility +│ └──Index.ets // Home page +├──resources // Static resources +│ ├──base // Default resources with unique IDs +│ │ ├──element // Fonts and colors +│ │ ├──media // Images +│ │ └──profile // Home page configuration +│ ├──en_US // Resources in American English +│ └──zh_CN // Resources in simplified Chinese +└──module.json5 // Module configuration +``` + +## How to Implement + +### UI Layer +1. Use PhotoViewPicker to select images from the Gallery. If the number of selected images is less than 2, a toast message is displayed, indicating that at least two images must be selected. +2. Iterate over the images, use createImageSource to decode the image files, use imageSource.createPixelMap to obtain the decoded PixelMap, and use pixelMap.readPixelsToBuffer to obtain the image data. +3. Store the pixelMap to the queue on the C side. + +### Native Layer +1. The input thread on the C side obtains the data to be encoded from the PixelMap queue and copies the data to the encoder input queue. +2. The output thread on the C side obtains the encoded data from the encoder output queue and sends the data to the muxer. +3. Stop the encoder and muxer once all images are processed. +4. In the encoding output thread, pop bufferInfo from the output queue, and write the corresponding data to the video file through the muxer. + +### UI Layer +1. Use the video component to play the generated video. +2. Use saveButton to save the video to Gallery. + +## Required Permissions + +- N/A + +## Dependencies + +- N/A + +## Constraints + +* This sample is only supported on Huawei phones running standard systems. +* The HarmonyOS version must be HarmonyOS 6.0.0 Release or later. +* The DevEco Studio version must be DevEco Studio 6.0.0 Release or later. +* The HarmonyOS SDK version must be HarmonyOS 6.0.0 Release SDK or later. + diff --git a/screenshots/device/effect_en.png b/screenshots/device/effect_en.png new file mode 100644 index 0000000000000000000000000000000000000000..3d01a97566825a60a18ddde959f7c4d4fa63fcb3 Binary files /dev/null and b/screenshots/device/effect_en.png differ