All Products
Search
Document Center

ApsaraVideo VOD:On-device super resolution

Last Updated:Mar 14, 2024

The on-device super resolution feature is developed based on the super resolution model on devices and allows you to convert videos of low definitions to those of high definitions on your device. This significantly improves video quality and reduces transmission costs. This topic describes how to configure the on-device super resolution feature on Android or iOS devices.

Background information

With the development of video services, users require video playback in higher definitions. However, specific video source files cannot be transcoded into video streams of high definitions due to production, storage, or distribution restrictions. This affects user experience. Traditional cloud-based ultra-high definition production solutions require high bandwidth. In this case, these solutions are not suitable for environments with poor network conditions.

The on-device super resolution feature allows you to convert videos of low definitions to those of high definitions on your device. This significantly improves video quality and user experience without raising the bandwidth cost.

Benefits

Item

Description

Performance and power consumption

  • Efficient: The processing time of a single frame from a video is less than 20 milliseconds. You can convert videos to super resolution at 30 frames per second (FPS) in real time. This feature can be used in various scenarios such as on-demand video playback and live streaming.

  • Powerful: Videos in multiple definitions can be converted. The highest definition of 540P is supported for real-time conversion. You can convert a 540P video to 1080P.

  • Power-saving: The power consumption varies based on the model, chip, and video resolution. The lowest power consumption is 50 mA to 100 mA per hour.

Compatibility

  • Model: This feature can be used on most mainstream models.

  • Platform: Android and iOS are supported.

Implementation method

  • Plug-in: The on-device super resolution feature is implemented by using a plug-in and is independent of the libraries of mainstream players. You can replace the plug-in or update the feature without affecting the player. This makes the on-device super resolution feature easy to use.

  • Small size: The feature library occupies a small space. The Android algorithm library occupies 408 KB and the iOS algorithm library occupies 730 KB.

Prerequisites

A license for ApsaraVideo Player SDK is obtained and the on-device super resolution feature is enabled. For more information, see Obtain a license.

Use the on-device super resolution feature in ApsaraVideo Player SDK for Android

  1. Obtain the on-device super resolution feature library.

    To obtain the super resolution feature library, submit a request on Yida or contact Alibaba Cloud customer service.

  2. Integrate the on-device super resolution feature library.

    1. Load the on-device super resolution feature library.

      The on-device super resolution feature library for Android is a dynamic library. You can call the following method to load the library:

      System.loadLibrary(libname);
    2. Configure the on-device super resolution feature library.

          /**
           * Configure the filter settings. Call this method before you prepare the player. Call the updateFilterConfig() method if you want to update filter settings.
           * @param filterConfig
           */
          /****
           * Set filter config. call this before prepare. If want update filter config, call updateFilterConfig()
           * @param filterConfig
           */
          abstract public void setFilterConfig(FilterConfig filterConfig);
      
          /**
           * Update filter settings.
           * @param target
           * @param options
           */
          /****
           * upadate filter config.
           * @param target
           * @param options
           */
          abstract public void updateFilterConfig(String target, FilterConfig.FilterOptions options);
      
          /**
           * Enable or disable the filter.
           * @param target  If you leave this parameter empty, the configurations take effect on all filters.
           * @param invalid  true indicates that the filter is enabled and false indicates that the filter is disabled.
           */
          /****
           * disable/enable filter.
           * @param target  if empty , disable all filters.
           * @param invalid  true: enable(default); false: disable
           */
          abstract public void setFilterInvalid(String target, boolean invalid);
  3. Use the on-device super resolution feature. Sample code:

    // filterConfig is a JSON string. Sample code:
    player.setFilterConfig(filterConfig);
    // Configure the on-device super resolution feature. The value of target must be the same as the value of target specified in the following method.
    player.setFilterInvalid(target,false);
    [
      {
        "target":"sr",
        "options":{
          // You do not need to configure option for the on-device super resolution feature.
        }
      }
    ]

Use the on-device super resolution feature in ApsaraVideo Player SDK for iOS

  1. Obtain the on-device super resolution feature library.

    To obtain the super resolution feature library, submit a request on Yida or contact Alibaba Cloud customer service.

  2. Integrate the on-device super resolution feature library.

    The on-device super resolution feature library for iOS is a dynamic framework. You must add the library to Frameworks and Libraries in Xcode. The following sample code provides an example on how to add the library.

    Note

    The following sample code uses ApsaraVideo Player SDK for iOS V5.5.4.0 as an example. You can download the SDK of the desired version based on your business requirements. For more information about different versions of ApsaraVideo Player SDK for iOS, see Release notes of ApsaraVideo Player SDK for iOS.

    pod 'AliPlayerSDK_iOS_NORMAL_SR_FILTER', '5.5.4.0'
  3. Use the on-device super resolution feature. Sample code:

    // Initialize the player.
    AVPFilter* srFilter = [[AVPFilter alloc] initWithTarget:@"normal_sr"]; // To use the library, you must set target to normal_sr.
    AVPFilterOptions* srOptions = [[AVPFilterOptions alloc] init];
    [srOptions setOptions:@"path" value:@"xxx"]; // Specify the relative path of the sandbox.
    [srFilter setOptions:srOptions];
    [filterConfig addFilter:srFilter];
    [self.player setFilterConfig:filterConfig];
    
    // Use the on-device super resolution feature.
    [self.player setFilterInvalid:@"normal_sr" invalid:YES]; // Set invalid to YES to enable the on-device super resolution feature and set invalid to NO to disable the feature.