All Products
Document Center

Video recording

Last Updated: Apr 03, 2020


The recording module of the Alibaba Cloud short video SDK provides the video recording feature. The professional edition of the short video SDK offers features such as filters, music, speed control, basic and advanced face filters, and facial motion graphics.

Integrate the recording feature

Step 1. Copy files

  • Copy modules.

Copy the following required modules into the directory of your project: AliyunSVideoBase, AliyunFileDownLoader, AliyunSvideoMusic, AliyunRecorder, AliyunVideoCommon, AlivcMedia, 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 integrating the recording feature

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:

  1. include ':AliyunVideoCommon'
  2. include ':AlivcMedia'
  3. include ':AliyunSVideoBase'
  4. include ':AliyunFileDownLoader'
  5. include ':AliyunSvideoMusic'
  6. include ':AliyunRecorder:record'
  • 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:

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


  • Add a Maven repository.

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

  1. allprojects {
  2. repositories {
  3. google()
  4. jcenter()
  5. maven { url "" }
  6. }
  7. }
  • Add dependencies.

Add the following dependency code to dependencies in the build.gradle file of the main module in your project. Generally, the main module name is app:

  1. implementation project(':AliyunFileDownLoader')
  2. implementation project(':AliyunSVideoBase')
  3. implementation project (":AliyunRecorder:record")
  • Delete code related to the editing module.

If you do not need to edit videos, delete the code for going to the editing modulefrom the AlivcSvideoRecordActivity and AlivcSvideoMixRecordActivity classes of the recording module. The sample code is as follows:

  1. videoRecordView.setCompleteListener(new AliyunSVideoRecordView.OnFinishListener() {
  2. @Override
  3. public void onComplete(String path, int duration) {
  4. // Go to the editing module. If you do not need to go to the editing module, modify the following code as required.
  5. MediaInfo mediaInfo = new MediaInfo();
  6. mediaInfo.filePath = path;
  7. mediaInfo.startTime = 0;
  8. mediaInfo.mimeType = "video";
  9. mediaInfo.duration = duration;
  10. List<MediaInfo> infoList = new ArrayList<>();
  11. infoList.add(mediaInfo );
  12. AlivcEditInputParam param = new AlivcEditInputParam.Builder()
  13. .setHasTailAnimation(false)
  14. .addMediaInfo(mediaInfo)
  15. .setCanReplaceMusic(isUseMusic)
  16. .setGop(mInputParam.getGop())
  17. .setBitrate(mInputParam.getBitrate())
  18. .setFrameRate(mInputParam.getFrame())
  19. .setVideoQuality(mInputParam.getVideoQuality())
  20. .setVideoCodec(mInputParam.getVideoCodec())
  21. .build();
  22. EditorActivity.startEdit(AlivcSvideoRecordActivity.this, param );
  23. }
  24. });

Delete the dependency configuration of the editing module from the build.gradle file of the recording module. The sample code is as follows:

  1. dependencies {
  2. implementation fileTree(include: ['*.jar'], dir: 'libs')
  3. api project(':AliyunSVideoBase')
  4. implementation project(":AliyunSvideoMusic")
  5. api project(path: ':AliyunFileDownLoader:downloadermanager')
  6. implementation externalGSON
  7. implementation externalFaceUnity
  8. implementation project(':AliyunEditor:editor_demo')// Delete dependencies of the editing module.
  9. }

Step 3. Set parameters for the recording feature

Note: The recording feature requires the camera access and storage permissions. To use this feature properly on devices in Android 6.0 or later versions, your application must request the camera access permission at runtime to avoid exceptions such as the black screen.

  • Create a MyApplication class to inherit the class or add the following code to the specified Application object of your project:
  1. @Override
  2. public void onCreate() {
  3. super.onCreate();
  4. QupaiHttpFinal.getInstance().initOkHttpFinal();
  5. DownloaderManager.getInstance().init(this);
  6. }
  • Access the recording UI.
  1. public void startRecord(View view) {
  2. AlivcRecordInputParam recordParam = new AlivcRecordInputParam.Builder()
  3. .build();
  4. AlivcSvideoRecordActivity.startRecord(this, recordParam);
  5. }

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 address: 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 file. Use this file to replace the file in your project. Make sure that the package name and signature are consistent in the two files.


  • 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 at [].