All Products
Search
Document Center

Basic Concept

Last Updated: Jul 30, 2019

Version information

The short video SDK provides the Version class to obtain the SDK version information. You can use the variables defined in this class to obtain the SDK version information. Such information can help us quickly locate your issues.

  1. public class Version {
  2. public static final String VERSION = "";
  3. public static final String BUILD_ID = "";
  4. public static final String SRC_COMMIT_ID = "";
  5. public static final String ALIVC_COMMIT_ID = "";
  6. public static final String ANDROID_COMMIT_ID = "";
  7. }

License

You need a license to use the short video SDK. For more information about how to apply for a license, see Introduction.

When applying for a license, make sure that the package name that you submit is the same as that configured in Android Studio.

Video resolution

The resolution of a video indicates the effective horizontal and vertical pixels of the video. Generally, a higher resolution indicates a clearer video. However, a higher resolution also indicates a larger file size and a longer processing time. Considering that the performance varies among mobile phones, we recommend that you use 720p or a lower resolution. The following table lists the common video resolutions.

1:1 3:4 9:16
480p 480 * 480 480 * 640 480 * 848
540p 540 * 540 540 * 720 540 * 960
720p 720 * 720 720 * 960 720 * 1280
1080p 1080 * 1080 1080 * 1440 1080 * 1920

During recording, you can use the void setMediaInfo(MediaInfo mediaInfo) method of AliyunIRecorder to set a resolution for the recorded video by setting the videoWidth and videoHeight attributes of a MediaInfo object.

During cropping, you can use the int setCropParam(CropParam param) method of AliyunICrop to set a resolution for the output video by setting the outputWidth and outputHeight attributes of a CropParam object.

During import, you can use the setVideoParam(AliyunVideoParam param) method of AliyunIImport to set a resolution for the output video by setting the mOutputWidth and mOutputHeight attributes of an AliyunVideoParam object.

Do not directly use the screen resolution (in pixels) of a mobile phone as the video resolution.

During recording, the aspect ratio specified by GLSurfaceView must be the same as that of the resolution configured for the recorded video. If the aspect ratios are different, the height of the recorded video is videoWidth multiplied by the aspect ratio specified by GLSurfaceView. Then, videoWidth and the calculated height are used as the final resolution of the recorded video.

Video rotation angle

A video file may contain the rotation angle information. The short video SDK allows you to set a rotation angle for the recorded video.When recording a video in landscape mode, you can use the void setRotation(int rotation) method of AliyunIRecorder to set the rotation angle of the camera. Then, the recorded video contains the rotation angle information.

Bitrate

The bitrate of a video indicates the number of bits transmitted per second. The unit is bit per second (bit/s). After you set a bitrate for a video, the video encoder compresses the video to the desired size. Within a certain range, a higher bitrate indicates a clearer video and a larger file size. The recommended bitrates are as follows:

  • 480p: 1,000,000 to 2,000,000
  • 540p: 2,000,000 to 3,000,000
  • 720p: 2,000,000 to 4,000,000
  • 1080p: 2,000,000 to 6,000,000

During recording, you can use the int setVideoBitrate(int bitrate) method of AliyunIRecorder to set a bitrate for the recorded video.

During cropping, you can use the int setCropParam(CropParam param) method of AliyunICrop to set a bitrate for the output video by setting the mVideoBitrate attribute of a CropParam object.

During import, you can use the setVideoParam(AliyunVideoParam param) method of AliyunIImport to set a bitrate for the output video by setting the mBitrate attribute an AliyunVideoParam object.

Frame rate

The frame rate of a video indicates the number of image frames displayed per second. The unit is frame per second (fps). A higher frame rate indicates a smoother video and a larger file size. The recommended video frame rate is 25 fps to 30 fps.

During recording, you can use the void setMediaInfo(MediaInfo mediaInfo) method of AliyunIRecorder to set a frame rate for the recorded video by setting the mEncoderFps attribute of a MediaInfo object.

During cropping, you can use the int setCropParam(CropParam param) method of AliyunICrop to set a frame rate for the output video by setting the frameRate attribute of a CropParam object.

During import, you can use the setVideoParam(AliyunVideoParam param) method of AliyunIImport to set a frame rate for the output video by setting the mFrameRate attribute of an AliyunVideoParam object.

Keyframe

Frame is the basic unit of video images. A video file is composed of multiple consecutive frames. A keyframe is also called an I-frame. It is important for interframe compression and encoding. During decoding, a complete image can be reconstructed only with a keyframe. Keyframes can be generated without referencing other images. A keyframe can be used as an image and a reference point for seeking.

GOP

A Group of Picture (GOP) is a collection of successive frames. A GOP starts with a keyframe, followed by a group of B-frames and P-frames. If the GOP size is too small, the number of keyframes increases in a video and the compression ratio decreases. If the GOP size is too large, seeking takes more time, and reverse playback freezes because a GOP must be decoded for playing the frames reversely. In the short video SDK, the default GOP size is 5. We recommend that you set the GOP size to a value within 5 to 30.

During recording, you can use the void setGop(int gop) method of AliyunIRecorder to set a GOP size for the recorded video.

During cropping, you can use the int setCropParam(CropParam param) method of AliyunICrop to set a GOP size for the output video by setting the gop attribute of a CropParam object.

During import, you can use the setVideoParam(AliyunVideoParam param) method of AliyunIImport to set a GOP size for the output video by setting the mGop attribute of an AliyunVideoParam object .

When adding the reverse playback effect during editing, you must transcode an imported video first if the video has a large GOP size.

Scaling mode

If the aspect ratio of a material (an image or a video) is different from that of the output video, you need to select a scaling mode. The short video SDK supports two scaling modes:

  • Cropping mode: maintains the original aspect ratio and crops the material to display only the content in the middle area.

  • Padding mode: maintains the original ratio and displays the complete material by filling the blank area with a specified color.

During cropping, you can use the int setCropParam(CropParam param) method of AliyunICrop to set a scaling mode for the output video by setting the mScaleMode attribute of a CropParam object.

During import, you can use the setVideoParam(AliyunVideoParam param) method of AliyunIImport to set a scaling mode for the output video by setting the mScaleMode attribute of an AliyunVideoParam object.

Encoding mode

The short video SDK supports two encoding modes:

  • Software encoding: is completed by the CPU. Compared with hardware encoding, software encoding allows you to set more parameters. At the same bitrate, a software-encoded video is clearer. However, software encoding is slow, the CPU load is high, and the mobile phone easily gets hot.
  • Hardware encoding: is completed by other hardware instead of the CPU. Hardware encoding is faster, and the CPU load is low. However, the clearness of a hardware-encoded video is slightly lower than that of a software-encoded video, and hardware encoding may fail on some Android devices.

Resources

Resources of the short video SDK include face recognition models, common filters, and animated filters. These SDK resources can be stored on the network or packaged into an APK file. Considering the size of the SDK resources, we recommend that you store the resources on the network and enable your application to download the resources when it is started.

Currently, the short video SDK cannot read resources from the assets folder. If the resources are packaged into the APK file of an application, they must be copied to the SD card after the application starts. You can obtain the resource files and usage instructions from the downloaded SDK package.

Supported formats

The short video SDK can import files in the formats listed in the following table.

Type Format
Video MP4, MOV, and FLV
Audio MP3, AAC, and PCM
Image JPG, PNG, and GIF