All Products
Search
Document Center

Video recording

Last Updated: Aug 01, 2019

Overview

The recording module of the Alibaba Cloud short video SDK provides the video recording feature. It varies in the basic, standard, and professional editions of the short video SDK. In addition to the basic recording feature, the basic edition also supports filters and the basic face filter. Based on the basic edition, the standard edition adds the video speed control and music features. The professional edition offers features such as filters, music, speed control, basic and advanced face filters, and facial motion graphics. This topic describes only the integration procedure for the professional edition.

Integrate the recording feature

Step 1: Import files

  • Import modules.

Copy the following required modules into the directory of your project: AlivcCore, AliyunSVideoBase, AliyunFileDownLoader, AliyunSvideoMusic, AliyunRecorder, AliyunVideoSdk, AliyunVideoCommon, and thirdparty-lib. In the following figure, the ApsaraVideoQuVideo project is a sample project and the selected modules are required ones copied from the demo. Copy files for SmartVideo recording

  • Import SO files.

Copy SO files from the app/src/main/jniLibs directory to the specified library folder of your project.

Name Description Required
libfdk-aac.so The dependent third-party audio library of the short video SDK. Yes
liblive-openh264.so The dependent third-party library of the short video SDK. Yes
libQuCore.so The core library of the short video SDK. Yes
libsvideo_alivcffmpeg.so The dependent third-party library of the short video SDK. Yes
libAliFaceAREngine.so The library related to facial recognition. No
libFaceAREngine.so The library related to facial recognition. No

Tips: Currently, the short video SDK provides a library folder for each of the following two CPU architectures: armeabi-v7a and arm64-v8a. Tips: Pay attention to the specified SO file folder of your project, which is app/src/main/jniLibs by default.

Step 2: Configure Gradle

  • Import modules.

Add the copied modules to the dependencies of your project. Copy the following code into the settings.gradle file of your project:

include ':AlivcCore'
include ':AliyunSVideoBase'
include ':AliyunFileDownLoader:downloadermanager'
include ':AliyunSvideoMusic'
include ':AliyunRecorder:record_demo'
include ':AliyunVideoSdk'
include ':AliyunVideoCommon'
  • Add a configuration file.

Because the demo configuration, such as some dependent third-party open source libraries and the SDK version, is managed in the configuration file config.gradle of the thirdparty-lib folder in a uniform manner, you need to import this file into your project. Copy the following code into the build.gradle file of your project and synchronize Gradle again:

apply from: 'thirdparty-lib/config.gradle'

add_thirdlib

  • Add a Maven repository.

Copy the following code into the build.gradle file of your project:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
    }
}
  • Add dependencies.

Add the following dependency code to dependencies in the build.gradle file of the main module (whose name is generally app) in your project:

implementation project(':AliyunRecorder:record_demo')
implementation externalAliyunOSS

Step 3: Use the feature

Tips: The recording feature needs camera access and storage permissions. To guarantee that you can use this feature properly on devices in Android 6.0 or later versions, you need to apply for a dynamic permission to handle exceptions such as the black screen.

  • Create a MyApplication class to inherit the android.app.Application class or add the following code to the specified Application object of your project:
@Override
    public void onCreate() {
        super.onCreate();

        QupaiHttpFinal.getInstance().initOkHttpFinal();
        DownloaderManager.getInstance().init(this);
    }
  • Accesses the recording UI.
public void startRecord(View view) {
        AliyunSnapVideoParam recordParam = new AliyunSnapVideoParam.Builder()
            .build();
        AlivcSvideoRecordActivity.startRecord(this, recordParam,"community");
    }
  • Register a redirect activity after recording. If you need to redirect users to a custom page after recording, register a redirect activity in the AliyunSvideoActionConfig class.
// Goes to the editing page by default after recording.
AliyunSvideoActionConfig.getInstance().registerRecordFinishActivity("com.aliyun.demo.editor.EditorActivity");

Enable the advanced face filter

The short video solution integrates the advanced face filter of FaceUnity. To use this advanced face filter, you only need to replace the relevant authpack certificate file with a FaceUnity certificate.

Obtain a FaceUnity certificate

You can send an email to apply for trial use and specify the advanced face filter of FaceUnity in the email. Alibaba Cloud will send a certificate to you by email. Email: videosdk@service.aliyun.com. Email content: Provide your application name, bundle ID, package name, and signature. The signature is an MD5 hash value in lowercase without colons (:).

After the application email is sent, you can receive an authpack.java file. Use this file to replace the authpack.java file in your project. Ensure that the package name and signature are consistent in the two files.

Note:

  • For more information about the core code for integrating the FaceUnity SDK into the recording module of the short video solution, see the FaceUnityManager class in the demo.
  • The advanced face filter is available only in the professional edition of the short video SDK.
  • For more information about how to completely integrate the FaceUnity SDK, see the procedure for integrating the FaceUnity SDK into the short video SDK.