This topic describes how to export videos by using the short video SDK for iOS.
Supported editions
Edition | Supported |
---|---|
Professional | Yes |
Standard | Yes |
Basic | Yes |
Related classes
Class | Description |
---|---|
AliyunIExporter | The class that is used to obtain the export controller, configure export parameters, and start exporting videos. |
AliyunIExporterCallback | The class that defines export callbacks, including the export completion callback, export progress callback, and export failure callback. |
AliyunVideoParam | The class that defines video parameters, including the encoding type and frame rate of the video that you want to export. |
Export control
Initialize the AliyunIExporter class to obtain the export controller, configure export parameters, and start exporting videos.
For more information about operation parameters, see AliyunIExporter and AliyunVideoParam.
// Obtain the export controller.
id<AliyunIExporter> exporter = [editor getExporter];
// Configure export parameters.
AliyunVideoParam *param = [[AliyunVideoParam alloc] init];
param.fps = 60;
param.gop = 250;
param.videoQuality = AliyunVideoQualityHight;
// ... For information about other parameters, see the API documentation.
[exporter setVideoParam:param];
// Set the output video watermark.
AliyunEffectImage *watermark = [[AliyunEffectImage alloc] initWithFile:watermarkPath];
watermarkPath.frame = CGRectMake(10, 10, 50, 50);
// ... For information about other parameters, see the API documentation.
[exporter setWaterMark:watermark];
// Set the end watermark.
AliyunEffectImage *tailWatermark = [[AliyunEffectImage alloc] initWithFile:watermarkPath];
tailWatermark.frame = CGRectMake(10, 10, 50, 50);
tailWatermark.endTime = 2;
// ... For information about other parameters, see the API documentation.
[exporter setTailWaterMark:tailWatermark];
// Start the export.
[exporter startExport:outputPath];
// Pause the export.
[exporter pauseExport];
// Resume the export.
[exporter resumeExport]
// Cancel the export.
[exporter cancelExport];
Callbacks
You can configure callbacks to obtain the export progress and status of videos in a timely manner. For more information about operation parameters, see AliyunIExporterCallback.
// Configure callbacks for the export status.
editor.exporterCallback = self;
// Status protocol: AliyunIExporterCallback
- (void)exporterDidEnd:(NSString *)outputPath {
// The callback for the end of the export.
}
- (void)exporterDidCancel {
// The callback for the cancellation of the export.
}
- (void)exportProgress:(float)progress {
// The callback for the export progress.
}
- (void)exportError:(int)errorCode {
// The callback for the export error.
}