前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >教你1天搭建自己的“微视”

教你1天搭建自己的“微视”

原创
作者头像
腾讯视频云终端团队
发布2018-06-28 20:59:59
2.4K1
发布2018-06-28 20:59:59
举报

第一步 登录腾讯云官网,开通短视频控制台,申请license

第二步 工程配置iOS或者Android

工程配置iOS

Xcode Project Settings

I. Supported Platform

  • SDK supports iOS 8.0 or above.

II. Development Environment

  • Xcode 8 or above
  • OS X 10.10 or above

III. Xcode Project Settings

A simple iOS Application project is shown below to illustrate how to configure SDK in an Xcode project.

1. Copy SDK File

In this example, an iOS project named HelloSDK is created, and the downloaded TXLiteAVSDK_UGC.framework is copied to the project directory. The figure below shows the directory structure.

2. Add Framework

Add TXLiteAVSDK_UGC.framework to the project. At the same time, add the following dependent libraries:

libz.tbd Accelerate.framework Bugly.framework

After you've added the above libraries, the project dependency shows as follows:

3. Add Header File

Add the search path for header file to "Build Settings" -> "Search Paths" -> "User Header Search Paths". Please note that this operation is not required. If you do not add the header file search path for TXLiteAVSDK_UGC, "TXLiteAVSDK_UGC/" needs to be added before the SDK-related header file when the header file is referenced, as shown below:

代码语言:txt
复制
#import "TXLiteAVSDK_UGC/TXUGCRecord.h"

IV. Verification

Next, call the SDK API in the codes of HelloSDK to obtain SDK version information and verify whether the project is correctly configured.

1. Reference the Header File

Reference the SDK header file at the beginning of ViewController.m:

代码语言:txt
复制
#import "TXLiteAVSDK_UGC/TXLiveBase.h"

2. Add Calling Code

Add the following code to the viewDidLoad method:

代码语言:txt
复制
- (void)viewDidLoad {
    [super viewDidLoad];
    // Print SDK version information
    NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]);
}

3. Compile and Run

If all of the above steps are performed correctly, the HelloSDK project can be compiled successfully. Run the App in the Debug mode. SDK version information is output in Xcode's Console pane.

2017-09-26 16:16:15.767 HelloSDK17929:7488566 SDK Version = 3.4.1761

Now, the project configuration is completed.

Printing LOG

Configure whether to print log in the console and set the log level in TXLiveBase. Codes are described as follows:

  • setConsoleEnabled Configure whether to print the output of SDK in the Xcode console.
  • setLogLevel Configure whether to allow SDK to print local log. By default, SDK writes log to the Documents/logs folder of the current App. For technical support, you are recommended to enable the sub-switch and provide the log file after a problem occurs. Thank you for your support.
  • View log file To reduce the storage volume of logs, Mini LVB SDK encrypts the log files stored locally and limits the number of logs. Therefore, you need to use the log Decompression Tool to view the text content of log.
代码语言:txt
复制
[TXLiveBase setConsoleEnabled:YES];
[TXLiveBase setLogLevel:LOGLEVEL_DEBUG];

工程配置Android

1. System Requirement

SDK can run on Android 4.0.3 (API 15) or above. However, hardware encoding can be enabled only on Android 4.3 (API 18) or above.

2. Development Environment

SDK development environment is described below. The App development environment does not need to be consistent with that of SDK, but it must be compatible with:

  • Android NDK: android-ndk-r12b
  • Android SDK Tools: android-sdk_25.0.2
    • minSdkVersion: 15
    • targetSdkVersion: 21
  • Android Studio (Android Studio is recommended, but you can also use Eclipse + ADT)

3. Integration Guide (aar)

3.1 New Project

3.2 Copy Files

Put the aar package under the project libs directory

3.3 Project Configuration

  • Add the code that references aar package to build.gradle under the project app directory:dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // Import the short video SDK aar compile(name: 'LiteAVSDK_UGC_3.4.1757', ext: 'aar') }
  • Add flatDir to build.gradle under the project directory, and specify the local library in it:allprojects { repositories { jcenter() flatDir { dirs 'libs' } } }
  • Specify ndk-compatible architecture in defaultConfig of build.gradle under the project directory: defaultConfig { applicationId "com.tencent.liteav.demo" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "2.0" ndk { abiFilters "armeabi", "armeabi-v7a" } }
  • Finally, compile Rebuild Project.

4 Integration Guide (jar)

4.1 Library Description

Decompress LiteAVSDK_UGC_3.4.1757.zip to get the libs directory, which mainly includes a jar file, as shown below:

jar file

Description

liteavsdk.jar

Mini LVB SDK android core library

For library related to the upload of short videos, jar files and a so file for uploading short videos can be found in the Demo\app\libs directory, as shown below:

jar file

Description

sha1utils.jar

JAR package that implements SHA calculation of files to be uploaded. This component is used for short video upload (TXUGCPublish) feature

cos-sdk-android.1.4.3.11.jar

File upload package of Tencent Cloud COS. This component is used for short video upload (TXUGCPublish) feature

okio-1.6.0.jar

An excellent open source network I/O component

okhttp-3.2.0.jar

An excellent open source HTTP component

so file

Description

libTXSHA1.so

JAR package that implements SHA calculation of files to be uploaded. This component is used for short video upload (TXUGCPublish) feature

4.2 Copy Files

If no jni loading path is previously specified in your project, we recommend that you put the jar package and so library under the /src/main/jniLibs directory, which is the default jni loading directory of android studio.

4.3. Project Configuration

Add the code that references jar package and so library to build.gradle under the project app directory:

代码语言:txt
复制
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // Import Tencent Cloud LVB SDK jar
    compile fileTree(dir: 'src/main/jniLibs', includes: ['*.jar'])
}

5. Configure App Permissions

Configure App permissions in AndroidManifest.xml. Generally, video Apps require the following permissions:

代码语言:txt
复制
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.Camera"/>
<uses-feature android:name="android.hardware.camera.autofocus" />

6. Verify

Call the SDK API in the project to get SDK version information and verify whether the project is correctly configured.

6.1 Reference SDK

Reference the class of SDK in MainActivity.java:

代码语言:txt
复制
import com.tencent.rtmp.TXLiveBase;

6.2 Call API

Call the API getSDKVersioin in onCreate to get version number:

代码语言:txt
复制
String sdkver = TXLiveBase.getSDKVersionStr();
Log.d("liteavsdk", "liteav sdk version is : " + sdkver);

6.3 Compile and Run

The demo project can be compiled successfully if all of the above steps are correctly performed. If you run the project, you can see the following log information in logcat:

09-26 19:30:36.547 19577-19577/ D/liteavsdk: liteav sdk version is : 3.4.1757

<a name="online_so"> </a>

7. Print LOG

Configure whether to print log in the console and set the log level in TXLiveBase. Codes are described as follows:

  • setConsoleEnabled Configure whether to print the output of SDK in the Android Studio console.
  • setLogLevel Configure whether to allow SDK to print local log. By default, SDK writes log to the log / tencent / liteav folder on sdcard. For technical support, you are recommended to enable the switch and provide the log file after a problem occurs. Thank you for your support.
  • View log file To reduce the storage volume of logs, Mini LVB SDK encrypts the log files stored locally and limits the number of logs. Therefore, you need to use the log Decompression Tool to view the text content of log.
代码语言:txt
复制
TXLiveBase.setConsoleEnabled(true);
TXLiveBase.setLogLevel(TXLiveConstants.LOG_LEVEL_DEBUG);

8. Troubleshooting

8.1 Compilation

If the following errors occur when you compile/run the project after importing the SDK into it:

代码语言:txt
复制
Caused by: android.view.InflateException: 
Binary XML file #14:Error inflating class com.tencent.rtmp.ui.TXCloudVideoView

Find the problem by following the steps below:

  • Check whether you have placed the jar package and so library into the jniLibs directory.
  • If you are using the full version of aar integration mode, check whether the x64 "so" library has been filtered out in defaultConfig of build.gradle under the project directory. This is because the acoustic component library used by the joint broadcasting feature in full version does not support mobile phones with x64 architecture at the moment. defaultConfig { applicationId "com.tencent.liteav.demo" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "2.0" ndk { abiFilters "armeabi", "armeabi-v7a" } }
  • Check the proguard rules to confirm that the SDK-related package names have been added to the non-proguard list.-keep class com.tencent.** { *; }

8.2 Short Video Publishing

After a file is published, no error message or callback response is returned. The following appears when the log is printed:

代码语言:txt
复制
 TaskManager: ExecutionException

This is because the libTXSHA1.so used for upload has not been properly integrated into the project. For more information, please see Integration Guide.

第三步 完成工程配置后,可进行【视频录制】功能的集成

如果你是iOS开发,可参考视频录制(iOS)

如果你是Android开发,可参考视频录制(Android)

第四步 完成【视频录制】功能的集成后,可继续集成【视频剪辑】功能

如果你是iOS开发,可参考视频编辑(iOS)

如果你是Android开发,可参考视频编辑(Android)

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第一步 登录腾讯云官网,开通短视频控制台,申请license
  • 第二步 工程配置iOS或者Android
    • Xcode Project Settings
      • I. Supported Platform
      • II. Development Environment
      • III. Xcode Project Settings
      • 1. Copy SDK File
      • 2. Add Framework
      • 3. Add Header File
      • IV. Verification
      • 1. Reference the Header File
      • 2. Add Calling Code
      • 3. Compile and Run
    • Printing LOG
      • 1. System Requirement
        • 2. Development Environment
          • 3. Integration Guide (aar)
            • 3.1 New Project
            • 3.2 Copy Files
            • 3.3 Project Configuration
          • 4 Integration Guide (jar)
            • 4.1 Library Description
            • 4.2 Copy Files
            • 4.3. Project Configuration
          • 5. Configure App Permissions
            • 6. Verify
              • 6.1 Reference SDK
              • 6.2 Call API
              • 6.3 Compile and Run
            • 7. Print LOG
              • 8. Troubleshooting
                • 8.1 Compilation
                • 8.2 Short Video Publishing
            • 第三步 完成工程配置后,可进行【视频录制】功能的集成
            • 第四步 完成【视频录制】功能的集成后,可继续集成【视频剪辑】功能
            相关产品与服务
            对象存储
            对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档