All Products
Document Center

Import for cropping

Last Updated: Apr 03, 2020


The cropping module of the Alibaba Cloud short video SDK provides the video cropping feature. You can crop video clips to adjust the duration of videos. You can also adjust the frame rate, bitrate, resolution, and aspect ratio of videos.

Step 1. Copy files

  • Copy the components listed in the following table to the directory where the xxx.xcodeproj file resides.

    | Component | Description | Required | | —————— | ————- | ————————- | | AlivcConmmon | The public components. | Yes | | AlivcCore | The public components of the short video SDK. | Yes | | AlivcCrop | The code for configuring the cropping UI. | Yes |

Step 2. Integrate CocoaPods

  • Add the following CocoaPods configuration to the PodFile. If the PodFile does not exist, run the cd command in Xcode to go to the root directory of your project, and then run the pod init command.

    1. pod 'AlivcCommon', :path => 'AlivcCommon/'
    2. pod 'AlivcCore', :path => 'AlivcCore/'
    3. pod 'AlivcCrop', :path => 'AlivcCrop/'
    4. pod 'VODUpload', :git => '',:tag => '1.5.3'
    5. pod 'QuCore-ThirdParty',:git => '',:tag => '3.10.0'
    6. pod 'AliyunVideoSDKPro',:git => '',:tag => '3.14.0'
    7. pod 'AlivcConan',:git => '',:tag => '1.0.2'
    8. pod 'AliyunRace',:git => '',:tag => '1.0.0'

Run the cd command to go to the directory of the PodFile in your project, and then run the following command:

  1. pod install

Step 3. Configure the project

  1. On the Build Setting page, set Enable Bitcode to No in the Build Options section.

  2. Configure the Info.plist file.

    Open the Info.plist file of your project and add the following fields:

    • Privacy - Photo Library Usage Description
    • Privacy - Photo Library Additions Usage Description

You can also add the following code to the source code of the Info.plist file:

  1. <key>NSPhotoLibraryAddUsageDescription</key>
  2. <string></string>
  3. <key>NSPhotoLibraryUsageDescription</key>
  4. <string></string>

Step 4. Use the feature

Go to the AliyunConfigureViewController controller to check the result of the preceding configuration.Take a new project as an example. Run the #import "AliyunConfigureViewController.h" command to import the header file of the controller to the SceneDelegate.m file, and then specify AliyunConfigureViewController as the root view controller. The sample code is as follows:

  1. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
  2. // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
  3. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
  4. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
  5. UIWindowScene *windowScene = (UIWindowScene *)scene;
  6. self.window = [[UIWindow alloc]initWithWindowScene:windowScene];
  7. AliyunConfigureViewController *vc = [[AliyunConfigureViewController alloc]init];
  8. vc.isClipConfig = @"YES";
  9. UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
  10. nav.navigationBar.hidden = YES;
  11. self.window.rootViewController = nav;
  12. [self.window makeKeyAndVisible];
  13. }

Run the project on a mobile phone to use the cropping feature.