Nowadays, short videos have become the main form of entertainment and social interaction for people, and many users have begun to gradually change from viewers to short video producers and communicators. However, complex video editing tools have stopped them. How can we lower the threshold for short video production and editing, so that more inexperienced people can produce high-quality short video content and be willing to share interesting life stories?

Huawei HMS Core video editing service version 6.6.0 recently launched the AI highlight feature, which can automatically identify and segment video footage based on artificial intelligence, and intelligently generate highlight videos based on user-defined durations. At the same time, you can also combine the highlight clip capability with the existing template capability to build a one-click filming capability, which can quickly generate complete and mature video works without manual editing, especially suitable for video content editing such as travel photography and daily shooting. .

design principle

The video editing service 's highlight clip capability combines user research and evaluation to analyze the video attributes that users care about the most. This characterizes the brilliance of the footage and meets the user's video clip value needs.

Aesthetic evaluation is a data set constructed from dimensional standard data such as composition, lighting, color, etc., and is an important reference standard for the realization of the highlight ability; content tags and character expressions refer to the highlight ability to intelligently identify and more inclined to edit the content. , such as video content with characters and animals, or video content with people laughing, will be preferentially edited and presented in the highlight clip; in addition, the highlight clip ability will filter out blur, blur, overexposure, and very jittery Take the essence and remove the dross, and finally present high-quality and mature highlights. The entire processing process is usually within 2 seconds.

Ability advantage

1. Through iterative optimization of the design model and scoring strategy, the professional evaluation and crowd-testing of video editing service's ability to highlight clips is better than that of industry peers, which can help the application fully tap the value of user video creation.

2. In order to improve the efficiency of generating and running highlights, the two-stage algorithm of "sparse sampling-dense sampling", combined with the distribution law of a large number of user videos, adopts strategies such as cache frames to quickly find clips that meet the requirements; using thread pool scheduling, producers can - The consumer model implements video decoding and model parallelism to help the algorithm run efficiently.

DEMO demo

Integrated approach

1. Development preparation

For detailed preparation steps, please refer to the official website of Huawei Developer Alliance

2. Edit project integration

2.1 Set the authentication information of the application

Application authentication information can be set through api_key or Access Token.

The Access Token is set through the setAccessToken method, which can be initialized and set once when the application starts, and there is no need to set it multiple times.

 MediaApplication.getInstance().setAccessToken("your access token");

The api_key is set by the setApiKey method, which can be initialized and set once when the application starts, and there is no need to set it multiple times.

 MediaApplication.getInstance().setApiKey("your ApiKey");

2.2 Set the unique identification ID, that is, the License ID.

The license ID is a valid certificate for management and control. You must ensure that the license ID is unique.

 MediaApplication.getInstance().setLicenseId("License ID");

2.2.1 Initialize the Editor runtime environment

To create an editing project, you need to first create an Editor object and initialize its runtime environment. When leaving the editing project, the Editor instance should be released.

(1) Create Editor object

 HuaweiVideoEditor editor = HuaweiVideoEditor.create(getApplicationContext());

(2) Specify the layout position of the preview window

The preview window is responsible for the rendering of video images, which is realized by creating SurfaceView inside the video editing atomic capability SDK. Before creating the window, you need to specify the layout position of the preview window in your app.

 <LinearLayout    
    android:id="@+id/video_content_layout"    
    android:layout_width="0dp"    
    android:layout_height="0dp"    
    android:background="@color/video_edit_main_bg_color"    
    android:gravity="center"    
    android:orientation="vertical" />
// 指定预览窗口 
LinearLayout mSdkPreviewContainer = view.findViewById(R.id.video_content_layout);

// 设置预览窗口承载的布局 
editor.setDisplay(mSdkPreviewContainer);

(3) Initialize the running environment. If the license authentication fails, a LicenseException will be thrown.

After the Editor object is created, the actual system resources are not occupied at this time, and the timing of its environment initialization needs to be manually selected. At this time, the necessary threads and timers will be created inside the Video Editing Atomic Capability SDK.

 try {
        editor.initEnvironment();
   } catch (LicenseException error) { 
        SmartLog.e(TAG, "initEnvironment failed: " + error.getErrorMsg());    
        finish();
        return;
   }

3. "Highlights" capability integration

 // 创建精彩片段处理对象
HVEVideoSelection hveVideoSelection = new HVEVideoSelection();
// 初始化精彩片段AI引擎
hveVideoSelection.initVideoSelectionEngine(new HVEAIInitialCallback() {
        @Override
        public void onProgress(int progress) {
        // 初始化进度
        }
        @Override
        public void onSuccess() {
            // 初始化成功
        }

        @Override
        public void onError(int errorCode, String errorMessage) {
            // 初始化失败
        }
});
        
// 初始化成功后,提取精彩片段,filePath为视频的路径,duration为需要提取片段的长度
hveVideoSelection.getHighLight(filePath, duration, new HVEVideoSelectionCallback() {
        @Override
        public void onResult(long start) {
            // 精彩片段提取成功
        }
});

// 释放精彩片段AI引擎
hveVideoSelection.releaseVideoSelectionEngine();

Learn more details>>

Visit the official website of Huawei Developer Alliance
Get development guidance documents
Huawei Mobile Services Open Source Warehouse Address: GitHub , Gitee

Follow us to know the latest technical information of HMS Core for the first time~


HarmonyOS_SDK
596 声望11.7k 粉丝

HarmonyOS SDK通过将HarmonyOS系统级能力对外开放,支撑开发者高效打造更纯净、更智能、更精致、更易用的鸿蒙应用,和开发者共同成长。