For video editing SDK access instructions, video editing sdk access

Source: Internet
Author: User

For video editing SDK access instructions, video editing sdk access

 

I. Runtime Environment

Android 4.1 (api 16) or above;

CPU: dual-core CPU above 1 GHz (currently only arm cpu is supported, X86 CPU and mips cpu are not supported); quad-core CPU above GHz is recommended

Memory: 1 GB or more;

 

2. Apply for AppKey and APPSECRET Registration

1. log on to the http://www.rdsdk.com to register the user

2. log on to the registered user

3. Go to video cloud management and click (ADD) to obtain the appkey and appsecret of the application.

 

3. Download and import SDK1 and Android Studio to import xpkUISdk

Click File ---> Import Module, select the path, and enter "Module name". The default value is xpkUISdk. Click "finish".

Click File ---> Project Structure, select the Module of your Project, and set Min Sdk Version not lower than 16 on the Flavors tab.

Switch to the Dependencies tab and click "+" on the right. In the displayed drop-down menu, select Module Dependency and click.

In the dialog box that appears, select the SDK-related Modules and click "OK"

Click "OK" on the Project Structure settings page to complete the import.

 

The solution to conflicts caused by integration of the ndk so library is as follows:

Step 1: filter the sdk library module

 

 

 

Step 2: filter data in the application module

Edit the sdk ndk to include the SO library of the following Architecture:

  • Armeabi-v7a

We recommend that you use the "abiFilter" configuration of NDK in the Module build. gradle file to set the supported SO Library Architecture.

If"AbiFilter"Then Android Studio displays the following prompt:

NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin.

In the root directory of the projectGradle. propertiesFile:

Android. useDeprecatedNdk = true

When integrating the ndk so library, note that only the supported architecture SO library is retained. Refer to the configuration

Binding SDK javadoc documents on Android studio

When using the SDK jar package in Android Studio, the xpkuisdk _ $ VERSTION $. xml file is generated in the $ PROJECT_DIR $/. idea/libraries directory and the following configuration is added:

<JAVADOC>
<RootUrl ="File: // $ PROJECT_DIR $/../xpkUISdk/docs/xpkUISdk"/>
</JAVADOC>

$ PROJECT_DIR $ indicates the project root directory. $ VERSTION $ indicates the SDK version. If the current version is 1.0.8, the XML file is xpkuisdk_1_0_8.xml;

The current configuration demo is based on the SDK demo project and needs to be modified according to the actual integration environment.

Refer to the following:

 

 

After adding JAVADOC, the result is as follows:

 

2. Import xpkUISdk to Eclipse

3, Prepare AndroidManifest. xml (permission, register Activity)

 

A. add permissions:

 

B. register the required Activity:

 

If you do not want to affect AndroidManifest. xml of the current project, you can merge the configuration in xpkUISdk in Eclipse and modify the project. properties file as follows:

Android. library. reference.1 = ../xpkUISdk

Manifestmerger. enabled = true

4. Replace the built-in dubbing

Replace the corresponding audio file with soundtrack. json

5. Call sdk Initialization

 

 

Other functional interfaces can be used normally only after Initialization is successful. Pay attention to the application for system permissions. Otherwise, the SDK cannot be used normally at the system api level> = 23 (android 6.0 + ).

 

6. Specify configuration parameters

After SDK Initialization is successful, you need to specify the configuration parameters when you need some custom functions. If you do not specify the parameters, they will not affect the usage, but will only be called according to the default configuration.

A. Interface Configuration example:

UIConfiguration uiConfig = new UIConfiguration. Builder ()

// Set the landscape and Landscape (supports landscape, landscape, and automatic)

. SetOrientation (orientation)

// Set whether to use a custom album. (If this parameter is set to false, the show album is called)

. UseCustomAlbum (useCustomAlbum)

// Set whether to enable wizard

. EnalbeWizard (enable)

// Sets the default video proportion.

. SetVideoProportion (proportion)

. Get ();

Set display and hide of the edit and export function module

UiConfig. setEditAndExportModuleVisibility (EditAndExportModules module,

Boolean visibility)

EditAndExportModules is an enumeration of the edit and export function modules.

Public enum EditAndExportModules {

/** Music */

SOUNDTRACK,

/** Dubbing */

DUBBING,

/** Filter */

FILTER,

/** Subtitle */

TITLING,

/** Special effects */

SPECIAL_EFFECTS,

/** Edit a clip */

CLIP_EDITING,

}

 

Set the display and hide of the fragment editing function module:

UiConfig. setClipEditingModuleVisibility (ClipEditingModules module,

Boolean visibility)

ClipEditingModules is an enumeration of the fragment editing module.

Public enum ClipEditingModules {

/** Video speed control */

VIDEO_SPEED_CONTROL,

/** Set the image length */

IMAGE_DURATION_CONTROL,

/** Copy */

COPY,

/** Edit an image or video */

EDIT,

/** Video ratio */

PROPORTION,

/** Collation */

SORT,

/** Intercept */

TRIM,

/** Split */

SPLIT,

}

If you select Custom album, the following interface is called back:

Com. rd. xpkuisdk. ISdkCallBack. getVideo (context) // Add a video

Com. rd. xpkuisdk. ISdkCallBack. getPhoto (context) // Add an image

In the above method, call custom album. After selecting a video or image, call the following method to complete the selection:

Com. rd. xpkuisdk. XpkSdk. onCustomizeAlbum (

Contextcontext, // application context

ArrayList <String> medialist // a set of video or image paths

)

B. Export video ConfigurationExample:

ExportConfiguration exportConfig = new ExportConfiguration. Builder ()

// Set the unit of the code stream when saving and exporting the video.

. SetVideoBitRate (bitRate)

// Set the unit of time (ms) for video Export (set to 0 or the full video will be exported by default)

. SetVideoDuration (exportVideoDuration)

// Set the Save path of the exported video (null will be saved to the default path)

. SetSavePath (savePath)

// Set the path of the video credits image (if it is set to null, there will be no credits)

. SetTrailerPath (trailerPath)

// Sets the unit of video credits (default value: 2000 ms)

. SetTrailerDuration (trailerDuration)

. Get ();

 

C. Recording and shooting ConfigurationExample:

CameraConfiguration cameraConfig = new CameraConfiguration. Builder ()

// Set the duration of the recorded video to 0 seconds, indicating that there is no time limit.

. SetVideoMaxTime (maxTime)

// Determine whether the Camera mode is supported. Click the photo button to return immediately.

. SetTakePhotoReturn (taskPhotoReturn)

// Set the default page mode when recording

. SetCameraUIType (type)

// Mute during recording

. SetAudioMute (mute)

. Get ();

 

The optional constants of CameraUIType are defined as follows:

// Indicates that the screen recording interface is enabled at by default and can be switched to the interface.

CameraConfiguration. WIDE_SCREEN_CAN_CHANGE

// Indicates that the interface is enabled by default and can be switched to the screen recording Interface

CameraConfiguration. SQUARE_SCREEN_CAN_CHANGE

// Indicates that the screen cannot be switched to the screen recording page by default.

CameraConfiguration. ONLY_SQUARE_SCREEN

Example of specifying configuration parameters:

XpkSdk. getXpksdkService (). initConfiguration (

ExportConfig, // export the configuration

UiConfig, // Interface Configuration

CameraConfig // specifies the recording configuration );

Iv. Recording Video 1. recording a video or taking a photo

Go to the interface and call the following interface:

Public static void com. rd. xpkuisdk. onXpkCamera (

Context context, // application Context

Boolean gotoEdit // enter the advanced editing page after recording is completed

)

After recording a video or recording a video and editing and exporting the video, the following APIs are called back:

Com. rd. xpkuisdk. ISdkCallBack. getVideoPath (

Context, // application context

ExportType, // edit the callback type after the export or recording is completed

VideoPath // specifies the video path.

)

The callback type exportType parameter value is defined as follows:

XpkSdk. XPK_CAMERA_EDIT_EXPORT // if the value of gotoEdit is true, it indicates that the recording is completed and the output is edited.

XpkSdk. XPK_CAMERA_EXPORT // if the value of gotoEdit is false, it indicates that only after recording is complete

5. Edit Video 1, Go to the sdk function interface (select media resources)

Void com. rd. xpkuisdk. XpkSdk. onXpkVideo (Context context // application Context)

2, Go to the sdk editing page (go to the editing page)

Void com. rd. xpkuisdk. XpkSdk. onXpkEdit (

Context context, // application Context

ArrayList <String> list // media path set (available image or video path)

)

3, Go to the sdk screenshot page (directly go to the screenshot page)

You can directly access the screenshot interface through the following interfaces:

Void com. rd. xpkuisdk. XpkSdk. onXpkTrimVideo (

Context context, // application Context

String videoPath, // media path

String savePath, // If the Save path is set to null after video capturing, it will be saved to the default path.../xpk/xpkVideos/

String title, // if the title bar text content is set to null, the title will be set to "truncated"

Int titleBarColor, // Title Bar background color

String buttonCancelText, // If the cancel button text is set to null, the icon X is displayed.

String buttonConfirmText, // If the confirmation button text is set to null, the icon √ is displayed.

Int buttonColor // button background color

);

There are two steps to complete the interception. The first step is to confirm the return method of the interception, and the second step is to return the final result through the corresponding callback interface through the return method.

Step 1: confirm the interception Return Method

The following interface is called back when the return method is intercepted:

Com. rd. xpkuisdk. ISdkCallBack. getVideoTrim (

Context, // application context

ExportType // callback type

)

The callback type exportType parameter value is defined as follows:

XpkSdk. XPK_TRIMVIDEO_EXPORT // Normal screenshot

XpkSdk. XPK_TRIMVIDEO_DURATION_EXPORT // fixed length Truncation

Step 2: Set the return truncation method

You can use the following interface to set the return interception method:

Void com. rd. xpkuisdk. XpkSdk. onVideoTrim (

Context context, // application Context

XpkSdk. XPK_TRIMVIDEO_DURATION_EXPORT // fixed length Truncation

RETURN_TRIM_TIME = 1 // return the truncation time

The screenshot interface returns the start time and end time of the video clip and performs the following callback:

Com. rd. xpkuisdk. ISdkCallBack. getVideoTrimTime (

Context, // application context

ExportType, // return the callback type of the truncation time

StartTime, // start time (unit: ms)

EndTime // End Time (unit: ms)

)

The callback type exportType parameter value is defined as follows:

XpkSdk. XPK_TRIMVIDEO_EXPORT // Normal screenshot

XpkSdk. XPK_TRIMVIDEO_DURATION_EXPORT // fixed length Truncation

Int returnType // specifies the return truncation method.

)

 

The returnType parameter value of the Return method is defined as follows:

RETURN_TRIM_VIDEO = 0 // return the captured video

After the video is captured and exported, the following interface will be called back:

Com. rd. xpkuisdk. ISdkCallBack. getVideoPath (

Context, // application context

ExportType, // capture and export the video callback type

VideoPath // specifies the path of the captured and exported video.

)

The callback type exportType parameter value is defined as follows:

XpkSdk. XPK_TRIMVIDEO_EXPORT // Normal screenshot

4. Export video

After editing, a video is generated based on the export configuration. After the export is completed, the following interface is called back:

Com. rd. xpkuisdk. ISdkCallBack. getVideoPath (

Context, // application context

ExportType, // export the video callback type

VideoPath // specifies the video path.

)

The callback type exportType parameter value is defined as follows:

XpkSdk. XPK_EDIT_EXPORT // return result after normal editing and export is complete

XpkSdk. XPK_CAMERA_EDIT_EXPORT // indicates that the recording is completed and the output is edited.

6. Respond to exit

When the application ends, you need to call the exit interface XpkSdk. exitApp of the SDK. Generally, the exit interface is in the onDestroy method of the Last Exit Activity. For details, see the demo.

7. Use a custom player

 

Com. rd. xpkuisdk. ui. XpkVideoView

1, Add a player to the layout File

 

2. Player Initialization

Void com. rd. xpkuisdk. XpkVideoView. setPlayerListener (XpkPlayerListener listener)

3. Player Interface

SetVideoPath (String videoPath) // sets the video path

Boolean isPlaying () // determines whether the player is playing

Void start () // start playing

Void pause () // pause playback

Int getCurrentPosition () // gets the current playback progress

Void seekTo (int position) // jump to the specified playback position (unit: ms)

Int getDuration () // gets the media length, in ms

8. share videos

None

9. Video watermark

For more information about how to add a watermark, see put a PNG Image in the assets Directory. The fixed name isWatermark.png

 

10. Packaging Obfuscation

Add the following configuration items to the proguard. cfg file:

-Dontwarn com. rd .**

-Keep class com. rd .**{*;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.