All Products
Search
Document Center

Production and upload

Last Updated: Jul 30, 2019

The short video SDK provides the video production and upload features. The core class is AliyunVodPublishManager. If you want to product and upload videos more flexibly, 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 for VOD.

Related class

Name Function
AliyunVodPublishManager The core production and upload class.

Produce and upload a video

Initialization

Create an AliyunVodPublishManager object and initialize it. AliyunVodPublishManager must use the AliyunIExporterCallback and AliyunIVodUploadCallback protocols to implement production and upload callbacks.

  • Production callbacks
  1. @property (nonatomic, weak) id<AliyunIExporterCallback> exportCallback;
  • Upload callbacks
  1. @property (nonatomic, weak) id<AliyunIUploadCallback> uploadCallback;

Production callbacks

AliyunIExporterCallback provides the following callbacks:

  • Callback to be called when the production starts
  1. - (void)exporterDidStart;
  • Production progress callback
  1. /**
  2. @param progress 0-1
  3. */
  4. - (void)exportProgress:(float)progress;
  • Callback to be called when a production exception occurs
  1. /**
  2. @param errorCode The error code.
  3. */
  4. - (void)exportError:(int)errorCode;
  • Callback to be called when the production is canceled
  1. - (void)exporterDidCancel;
  • Callback to be called when the production is completed
  1. /**
  2. @param outputPath The path of the output file.
  3. */
  4. - (void)exporterDidEnd:(NSString *)outputPath;

Upload callbacks

AliyunIVodUploadCallback provides the following callbacks:

  • Callback to be called when the upload is successful
  1. - (void)publishManagerUploadSuccess:(AliyunVodPublishManager *)manager;
  • Callback to be called when the upload fails
  1. - (void)publishManager:(AliyunVodPublishManager *)manager uploadFailedWithCode:(NSString *)code message:(NSString *)message;
  • Upload progress callback
  1. - (void)publishManager:(AliyunVodPublishManager *)manager uploadProgressWithUploadedSize:(long long)uploadedSize totalSize:(long long)totalSize;
  • Callback to be called when the token expires
  1. - (void)publishManagerUploadTokenExpired:(AliyunVodPublishManager *)manager;
  • Callback to be called when the upload times out and retrying starts
  1. - (void)publishManagerUploadRetry:(AliyunVodPublishManager *)manager;
  • Callback to be called when the retrying is completed and the upload continues
  1. - (void)publishManagerUploadRetryResume:(AliyunVodPublishManager *)manager;

Control production

  • Produce a video.
  1. /**
  2. Produces a video.
  3. @param taskPath The path of the folder for storing configuration information.
  4. @param outputPath The path of the produced video.
  5. @return The return value.
  6. */
  7. - (int)exportWithTaskPath:(NSString *)taskPath outputPath:(NSString *)outputPath;

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.

  • Cancel the production.
  1. - (int)cancelExport;

Control upload

  • Upload an image.
  1. /**
  2. Uploads an image as the thumbnail.
  3. @param imagePath The path of the thumbnail image.
  4. @param vodUploadAddress The upload URL provided by ApsaraVideo for VOD.
  5. @param vodUploadAuth The upload credential provided by ApsaraVideo for VOD.
  6. @return The return value.
  7. */
  8. - (int)uploadImageWithPath:(NSString *)imagePath
  9. uploadAddress:(NSString *)vodUploadAddress
  10. uploadAuth:(NSString *)vodUploadAuth;

After you call this method, the uploadState property of the AliyunVodPublishManager object is set to AliyunVodUploadImage.

For more information about the upload URL and credential of ApsaraVideo for VOD, see this document.

  • Upload a video.
  1. - (int)uploadVideoWithPath:(NSString *)videoPath
  2. uploadAddress:(NSString *)vodUploadAddress
  3. uploadAuth:(NSString *)vodUploadAuth;

After you call this method, the uploadState property of the AliyunVodPublishManager object is set to AliyunVodUploadVideo.

For more information about the upload URL and credential of ApsaraVideo for VOD, see this document.

  • Cancel the upload.
  1. - (void)cancelUpload;
  • Update the upload credential.

An upload timeout triggers the - (void)uploadTokenExpired callback. You need to call the following method in the callback to update the upload credential for the upload to continue:

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