All Products
Search
Document Center

Recording

Last Updated: Jul 30, 2019

The short video SDK provides the basic recording feature and allows you to add recording effects such as music, speed adjustment, and face stickers. The core recording interface is AliyunIRecorder.

Edition difference

Edition Description
Professional edition All features are supported.
Standard edition The basic recording and music features are supported. The facial recognition feature is not supported.
Basic edition The basic recording feature is supported. The music and facial recognition features are not supported.

Recording process

The camera and microphone permissions are required for recording. Otherwise, the recording fails. The video recording process is as follows:

1. Set parameters.
2. Control preview.
3. Control and manage recording.
4. Configure effects.
5. Start recording.
6. Complete recording.

Set parameters

Initialization

  • Create a recording instance.
    1. AliyunIRecorder recorder = AliyunRecorderCreator.getRecorderInstance(Context context); // The context parameter indicates the context of the current screen.
  • Destroy a recording instance.
    1. AliyunIRecorder#destroy();

Set output parameters

  • Set output parameters for the recorded video, including the preview frame rate, encoding frame rate, output resolution, and encoder type.
  1. AliyunIRecorder#setMediaInfo(MediaInfo mediaInfo); // For more information, see MedianInfo in the SDK documentation.
  • Set the path of the recorded video.
  1. AliyunIRecorder#setOutputPath(String path);
  • Set the quality of the recorded video.
  1. AliyunIRecorder#setVideoQuality(VideoQuality quality);
  • Set the bitrate of the recorded video.
  1. AliyunIRecorder#setVideoBitrate(int bitrate);// Unit: kbit/s.
  • Set the GOP size of the recorded video.
  1. AliyunIRecorder#setGop(int gop); // Unit: number of frames.

Set callbacks

  • Set the recording callback.
  1. AliyunIRecorder#setRecordCallBack(RecordCallback callBack);
  • Set the video frame collection callback.
  1. AliyunIRecorder#setOnFrameCallback(OnFrameCallBack callback);
  • Set the audio collection callback.
  1. AliyunIRecorder#setOnAudioCallback(OnAudioCallBack callback);

Control preview

  • Start the preview.
    1. AliyunIRecorder#startPreview();
  • Stop the preview.
    1. AliyunIRecorder#stopPreview();

Control and manage recording

Control recording

  • Obtain the number of cameras.
    1. AliyunIRecorder#getCameraCount();
  • Set the camera type.
    1. AliyunIRecorder#setCamera(CameraType cameraType);
  • Set the camera parameters, including the flash mode, focus mode, zoom, and exposure.
    1. AliyunIRecorder#setCameraParam(CameraParam
    2. cameraParam); // You can also set each camera parameter separately. For more information, see the following methods.
  • Switch between the front and rear cameras.
    1. AliyunIRecorder#switchCamera();
  • Set the flash mode.
    1. AliyunIRecorder#setLight(FlashType flashType);
  • Set the zoom.
    1. AliyunIRecorder#setZoom(float rate);
  • Set the exposure.
    1. AliyunIRecorder#setExposureCompensationRatio(float value);
  • Set the focus mode.
    1. AliyunIRecorder#setFocusMode(int mode);
  • Manually adjust the focus.
    1. AliyunIRecorder#setFocus(float xRatio, float yRatio);
  • Set the recording preview window view (GLSurfaceView).
    1. AliyunIRecorder#setDisplayView(GLSurfaceView glSurfaceView); // The glSurfaceView parameter is an object of the custom GLSurfaceView class or its subclass.
  • Set the sensor rotation angle. (This parameter is very important. Read the SDK documentation carefully.)
    1. AliyunIRecorder#setRotation(int rotation);
  • Set the face detection angle. (This parameter is very important. Read the SDK documentation carefully.)
    1. AliyunIRecorder#setFaceDetectRotation(int rotation);
  • Set the video recording angle. (This parameter is very important. Read the SDK documentation carefully.)
    1. AliyunIRecorder#setRecordRotation(int rotation);
  • Set whether to mute the audio during recording.
    1. AliyunIRecorder#setMute(boolean isMute);

Manage recording

  • Obtain the clip manager.
  1. AliyunIRecorder#getClipManager();
  • Set the maximum recording duration, which is the maximum duration of all clips instead of the maximum duration of a single clip.
  1. AliyunIClipManager#setMaxDuration(int maxDurationMs);
  • Set the minimum recording duration, which is the minimum duration of all clips instead of the minimum duration of a single clip.
  1. AliyunIClipManager#setMinDuration(int minDurationMs);
  • Obtain the total duration of clips.
  1. AliyunIClipManager#getDuration();
  • Obtain the total number of clips.
  1. AliyunIClipManager#getPartCount();
  • Delete the last clip.
  1. AliyunIClipManager#deletePart();
  • Delete the specified clip.
  1. AliyunIClipManager#deletePart(int index);
  • Delete all clips.
  1. AliyunIClipManager#deleteAllPart();
  • Obtain the clip path list.
  1. AliyunIClipManager#getVideoPathList();

Configure effects

Beautification

  • Set the beautification level.
    1. AliyunIRecorder#setBeautyLevel(int level);
  • Turn on or off the beautification switch.
    1. AliyunIRecorder#setBeautyStatus(boolean on);

Common filter

  • Add a common filter.
  1. AliyunIRecorder#applyFilter(EffectFilter effectFilter);
  • Remove a common filter.
  1. AliyunIRecorder#applyFilter(new EffectFilter(null)); // Removes a common filter by setting its path to null.

Animated filter

  • Add an animated filter, for example, the filter providing the effect of spirit freed from the body.
  1. AliyunIRecorder#applyAnimationFilter(EffectFilter effectFilter);
  • Remove an animated filter.
  1. AliyunIRecorder#removeAnimationFilter(EffectFilter effctFilter);

Facial recognition (supported only in the professional edition)

  • Set face coordinates. They are required by third-party facial recognition products.
  1. AliyunIRecorder#setFace(float[][] faces);
  • Set whether to use the built-in facial recognition feature of the SDK.
  1. AliyunIRecorder#needFaceTrackInternal(boolean need);
  • Specify a model file for the built-in facial recognition feature of the SDK.
  1. AliyunIRecorder#setFaceTrackInternalModelPath(String path);
  • Set the maximum number of faces supported by the built-in facial recognition feature of the SDK.
  1. AliyunIRecorder#setFaceTrackInternalMaxFaceCount(int maxFaceCount);

Animated sticker (supported only in the professional edition)

  • Add an animated face sticker.
  1. AliyunIRecorder#addPaster(EffectPaster effectPaster);
  • Add a common animated sticker.
  1. AliyunIRecorder#addPaster(EffectPaster effectPaster,float sx,float sy,float sw,float sh,float rotation,boolean flip);
  • Remove an animated sticker.
  1. AliyunIRecorder#removePaster(EffectPaster effectPaster);

Static watermark and static sticker

  • Add a static watermark or a static sticker.
  1. AliyunIRecorder#addImage(EffectImage effctImage);
  • Remove a static watermark or a static sticker.
  1. AliyunIRecorder#removeImage(EffectImage effctImage);

Background music (supported in the professional edition and standard edition)

  • Set the background music.
  1. AliyunIRecorder#setMusic(String path,long startTime,long duration);
  • Remove the background music.
  1. AliyunIRecorder#setMusic(null, 0, 0);

Speed adjustment (supported in the professional edition and standard edition)

  • Configure the recording speed.
  1. AliyunIRecorder#setRate(float rate);

Custom rendering

  • Set the callback for custom rendering.
  1. AliyunIRecorder#setOnTextureIdCallback(OnTextureIdCallBack callback);

Photo taking

  • Take a photo with effects.
  1. AliyunIRecorder#takePhoto(boolean needBitmap);
  • Take a photo by using the system camera feature. The photo does not contain effects.
  1. AliyunIRecorder#takePicture(boolean needBitmap);
  • Set the photo size. (This method is supported only for photo taking using the system camera feature.)
  1. AliyunIRecorder#setPictureSize(Camera.Size size);

Others

  • Set the effect information, for example, the position and size of a watermark, a static sticker, or an animated sticker.
  1. AliyunIRecorder#setEffectView(float xRatio,float yRatio,float widthRatio,float heightRatio,EffectBase effectBase);

Start recording

  • Start recording a video clip.
  1. AliyunIRecorder#startRecording();
  • Cancel recording a video clip.
  1. AliyunIRecorder#cancelRecording();
  • Stop recording a video clip.
  1. AliyunIRecorder#stopRecording();

Complete recording

  • Complete recording and merge recorded video clips into one video.
  1. AliyunIRecorder#finishRecording();
  • Complete recording and generate the configurations of the video clips without merging the clips.
  1. AliyunIRecorder#finishRecordingForEdit();