Features

The short video SDK allows you to produce and upload videos. The core class is AliyunVodPublishManager. If you want to produce and upload videos in a more flexible manner, you can use the AliyunEdit class together with the VODUpload framework.

Edition difference

Edition Description
Professional Edition All features are supported.
Standard Edition All features are supported.
Basic Edition The production and upload features are not supported. You can use the VODUpload framework to upload videos and images to ApsaraVideo VOD.

Related class

Name Description
AliyunVodPublishManager The core class for production and upload.

Initialization

Create an AliyunVodPublishManager object and initialize it. The AliyunVodPublishManager object must use the AliyunIExporterCallback and AliyunIVodUploadCallback protocols to fire production and upload callbacks.
Callback Sample code
Production callbacks
@property (nonatomic, weak) id<AliyunIExporterCallback> exportCallback;
Upload callbacks
@property (nonatomic, weak) id<AliyunIUploadCallback> uploadCallback;

Production callbacks

The following table describes the callback events that are supported by AliyunIExporterCallback.
Callback event Sample code
The production starts.
 - (void)exporterDidStart;
The production progress is monitored.
 /**
 @param progress 0-1
 */
 - (void)exportProgress:(float)progress;
A production error occurs.
 /**
 @param errorCode The error code.
 */
 - (void)exportError:(int)errorCode;
The production is canceled.
 - (void)exporterDidCancel;
The production is completed.
  /**
 @param outputPath The path of the output file.
 */
 - (void)exporterDidEnd:(NSString *)outputPath;

Upload callbacks

The following table describes the callback events that are supported by AliyunIVodUploadCallback.
Callback event Sample code
The upload is successful.
- (void)publishManagerUploadSuccess:(AliyunVodPublishManager *)manager;
The upload fails.
- (void)publishManager:(AliyunVodPublishManager *)manager uploadFailedWithCode:(NSString *)code message:(NSString *)message;
The upload progress is monitored.
- (void)publishManager:(AliyunVodPublishManager *)manager uploadProgressWithUploadedSize:(long long)uploadedSize totalSize:(long long)totalSize;
The token expires.
- (void)publishManagerUploadTokenExpired:(AliyunVodPublishManager *)manager;
The upload times out and a retry starts.
- (void)publishManagerUploadRetry:(AliyunVodPublishManager *)manager;
The retry is completed and the upload resumes.
- (void)publishManagerUploadRetryResume:(AliyunVodPublishManager *)manager;

Production control

Action Sample code
Produce a video.

The taskPath parameter can be passed in after editing or directly generated by AliyunIImporter. The outputPath parameter specifies the path of the produced video. If the path contains folders in multiple levels, make sure that the folders have been created.

/**
 Produce a video.
 @param taskPath taskPath
 @param outputPath The path of the produced video.
 @return The return value.
 */
- (int)exportWithTaskPath:(NSString *)taskPath outputPath:(NSString *)outputPath;
Cancel the production.
- (int)cancelExport;

Upload control

Action Sample code
Upload an image.

After you call this method to upload an image, the uploadState attribute of the AliyunVodPublishManager object is set to AliyunVodUploadImage. For more information about the upload URL and credential that are provided by ApsaraVideo VOD, see Use the upload URL and credential.

/**
 Upload a thumbnail.
 @param imagePath The path of the thumbnail.
 @param vodUploadAddress The upload URL that is provided by ApsaraVideo VOD.
 @param vodUploadAuth The upload credential that is provided by ApsaraVideo VOD.
 @return The return value.
 */
- (int)uploadImageWithPath:(NSString *)imagePath
              uploadAddress:(NSString *)vodUploadAddress
                 uploadAuth:(NSString *)vodUploadAuth;
Upload a video.

After you call this method to upload a video, the uploadState attribute of the AliyunVodPublishManager object is set to AliyunVodUploadVideo. For more information about the upload URL and credential that are provided by ApsaraVideo VOD, see Use the upload URL and credential.

- (int)uploadVideoWithPath:(NSString *)videoPath
              uploadAddress:(NSString *)vodUploadAddress
                 uploadAuth:(NSString *)vodUploadAuth;
Cancel the upload.
 - (void)cancelUpload;
Update the upload credential.

If an upload times out, the - (void)uploadTokenExpired callback is fired. You must call the following method in the callback to update the upload credential for the upload to continue:

- (int)refreshWithUploadAuth:(NSString *)vodUploadAuth;