Export videos

更新时间:
复制 MD 格式

The video export process includes exporting video configurations as well as producing and uploading videos. This topic describes how to export videos.

Supported editions

Edition

Supported

Professional

Yes

Standard

Yes

Basic

No

Related classes

Class

Description

AliyunVideoParam

A class that defines the parameters for video production and export.

AliyunIVodCompose

A class that defines video production and upload features, such as video initialization and production, video upload, and upload credentials update.

AliyunComposeFactory

A factory class that is used to create production instances.

Procedure of video export

Step

Description

Sample code

1

Export the configurations of the current video.

Export video configurations

2

Produce the video. You can set the pause, resume, and cancel features.

Produce a video

3

Upload the video. You can set the pause, continue, and cancel features.

Upload a video

4

Release resources.

Release resources

Note
  • The production API operation must be called before the upload API operation.

  • The production API operation can be called multiple times. The upload API operation uploads only the latest video that is produced.

  • If a video is edited, you must save the effects that are added to the video to the on-premises configuration file before you create an AliyunIVodCompose instance. Otherwise, the produced video does not contain these effects. To save added effects to the on-premises configuration file, call the following API operation:

    AliyunIEditor.saveEffectToLocal();

Export video configurations

In this step, the configurations of the current video are exported. The final video file is not produced and exported.

For more information about operation parameters, see AliyunVideoParam.

// Export the video configurations and generate the configuration file of the path in which the output video is stored.
AliyunIEditor.compose(AliyunVideoParam param, String outputPath, AliyunIComposeCallBack callback);

// Cancel the export of the video configurations.
AliyunIEditor.cancelCompose();

Produce the video

The short video SDK provides a set of API operations to implement the video production and upload features. You can use the AliyunIVodCompose core class to produce and upload edited videos on a dedicated user interface (UI). The production API operation can be called multiple times.

For more information about operation parameters, see AliyunIVodCompose and AliyunComposeFactory.

Initialize and produce the instance to be uploaded.

// Create an instance.
AliyunComposeFactory.createAliyunVodCompose();

// Initialize the instance.
AliyunIVodCompose.init(Context context);

Produce the instance.

AliyunIVodCompose.compose(String config, String output, AliyunIComposeCallBack callback);

Control the video production as needed.

// Pause the production.
AliyunIVodCompose.pauseCompose();
// Resume the production.
AliyunIVodCompose.resumeCompose();
// Cancel the production.
AliyunIVodCompose.cancelCompose();

Upload the video

After the video is produced, call the upload API operation to upload the video. The upload API operation uploads only the latest video that is produced.

For more information about operation parameters, see AliyunIVodCompose and AliyunComposeFactory.

Upload the video.

  • Obtain the upload address and credential.

    The AliyunIVodCompose class uploads a video by using an upload URL and credential. Before you upload the video, you must obtain the upload URL and credential. For more information, see CreateUploadVideo.

  • Upload the video file to an OSS bucket.

    /**
     * Upload the video to ApsaraVideo VOD. 
     * @param The options parameter specifies the video upload configurations. The following content describes the configurations.
     * videoPath: The path of the local video file. 
     * uploadAddress: The video upload URL provided by Alibaba Cloud. 
     * uploadAuth: The upload credential provided by Alibaba Cloud. 
     * aliyunVodUploadCallBack: The callback for the upload process. 
     */
    AliyunIVodCompose.uploadVideoWithVod(VideoUploadOptions options);
  • Refresh the upload credentials.

    Upload credentials have a validity period. After the video is uploaded, you must call onUploadTokenExpired to re-obtain the upload credential and then use AliyunIVodCompose.refreshWithUploadAuth(String uploadAuth) to update the upload credential. For more information, see RefreshUploadVideo.

(Optional) Manage the upload

// Pause the upload.
AliyunIVodCompose.pauseUpload();
// Resume the upload.
AliyunIVodCompose.resumeUpload();
// Cancel the upload.
AliyunIVodCompose.cancelUpload();

Release resources

After the upload is complete, destroy the upload instance that you used and release the resources.

AliyunIVodCompose.release();