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 |
|
Compatibility |
|
Implementation method |
|
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
Obtain the on-device super resolution feature library.
To obtain the super resolution feature library, submit a ticket or contact Alibaba Cloud customer service.
Integrate the on-device super resolution feature library.
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);
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);
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
Obtain the on-device super resolution feature library.
To obtain the super resolution feature library,submit a ticket or contact Alibaba Cloud customer service.
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.
NoteThe 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'
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.