Skip to content

Commit

Permalink
Merge pull request #210 from ShaoLongFei/v3.4.0
Browse files Browse the repository at this point in the history
Release v3.4.0
  • Loading branch information
BoleLiu authored May 31, 2022
2 parents 7ff285c + 1f7aef8 commit 09729a6
Show file tree
Hide file tree
Showing 1,006 changed files with 2,113 additions and 1,753 deletions.
66 changes: 66 additions & 0 deletions ReleaseNotes/release-notes-3.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# PLDroidShortVideo Release Notes for 3.4.0

### 简介

PLDroidShortVideo 是七牛推出的一款适用于 Android 平台的短视频 SDK,提供了包括美颜、滤镜、水印、断点录制、分段回删、视频编辑、混音特效、本地/云端存储在内的多种功能,支持高度定制以及二次开发。

### 版本

* 发布 pldroid-shortvideo-3.4.0.jar
* 更新上传库依赖版本到 v8.4.3

### 功能

* PLMediaFile 增加方法支持判断视频编码格式是否为 H.265
* PLDisplayMode 增加 KEEP 模式
* 视频录制支持无麦克风权限
* 优化混音切换逻辑
* 编辑模块水印设置支持层级设置
* 优化软编码的内存使用情况
* 视频录制的同时支持旋转摄像头
* 支持单个 GIF 转视频操作
* 转码、编辑、图片转视频模块支持软编码
* 水印增加角度设置
* PLMicrophoneSetting 增加判断手机是否支持双声道的方法
* 优化编码处理方式
* 优化预览视图,使其即时相应外部视图宽高变化
* 优化抽帧操作的耗时
* 优化 SDK 所需权限,极大限度降低所需的权限
* 支持自动曝光

### 缺陷

* 修复极慢速录制预览可能卡顿的问题
* 修复个别机型转码时码率达不到预期的问题
* 修复转码后的视频在存储到云端后使用在线播放时出现大量 206 请求的问题
* 修复录屏偶现无视频帧的问题
* 修复编辑模块在一帧添加大量 GIF 时出现部分 GIF 丢失的问题
* 修复偶现的 ANR 问题
* 修复在部分三星手机转码进度卡住的问题
* 修复在部分机型上图片转视频出现色差的问题
* 修复转码部分视频进度会卡住的问题
* 修复部分机型切换摄像头时出现画面缩放的一帧的问题
* 修复编码因异常停止后此后不能再启动的问题
* 修复转码默认的画面拉伸模式的问题
* 修复连续转码后续修改参数无效的问题
* 修复偶现的 OpenGL 环境创建崩溃的问题
* 修复频繁进行添加删除 GIF 操作导致结果异常的问题
* 修复部分机型录制帧率不达预期的问题
* 修复部分机型使用软编出现卡住的问题
* 修复部分机型后置转前置出现的预览异常问题
* 修复软编码视频可能出现的进度卡住问题

### 注意事项

* 从 v3.1.0 版本开始,需要在 Application 中初始化 sdk:

```java
PLShortVideoEnv.init(getApplicationContext());
```

* 七牛短视频 SDK 自 v3.0.0 版本起, 划分为精简版、基础版、进阶版、专业版。不同版本 SDK 可以使用的功能点数量有差别,请按照购买的 License 版本使用对应的短视频 SDK 版本。
* 上传 SDK 的依赖需要更新到如下版本:

```java
compile 'com.qiniu:qiniu-android-sdk:8.4.3'
```
10 changes: 5 additions & 5 deletions ShortVideoFunctionDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.qiniu.pili.droid.shortvideo.demo"
minSdkVersion 21
targetSdkVersion 30
versionCode 34
versionName "3.3.0"
versionCode 35
versionName "3.4.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
Expand All @@ -40,9 +40,9 @@ android {

dependencies {
// 上传 sdk ,不使用上传功能无需依赖
implementation 'com.qiniu:qiniu-android-sdk:8.3.2'
implementation 'com.qiniu:qiniu-android-sdk:8.4.3'
// 播放器 sdk ,非必须
implementation files('libs/pldroid-player-2.2.2.jar')
implementation files('libs/pldroid-player-2.3.3.jar')
// UI 控件库,非必须
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
Expand All @@ -59,6 +59,6 @@ dependencies {
implementation project(':library')
} else {
// 短视频 SDK jar 包,必须依赖
implementation files('libs/pldroid-shortvideo-3.3.0.jar')
implementation files('libs/pldroid-shortvideo-3.4.0.jar')
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion ShortVideoFunctionDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.qiniu.pili.droid.shortvideo.demo">

<uses-permission android:name="android.permission.CAMERA" />
Expand All @@ -9,6 +10,9 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />

<application
android:name=".ShortVideoApplication"
Expand All @@ -17,8 +21,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.ConfigActivity" />
<activity android:name=".activity.MainActivity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
mShortAudioRecorder.prepare(this, microphoneSetting, audioEncodeSetting, recordSetting);

mSectionProgressBar.setFirstPointTime(RecordSettings.DEFAULT_MIN_RECORD_DURATION);
mSectionProgressBar.setTotalTime(this, recordSetting.getMaxRecordDuration());
mSectionProgressBar.setTotalTime(recordSetting.getMaxRecordDuration());

mRecordBtn.setOnClickListener(v -> {
if (mSectionBegan) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected void onCreate(Bundle savedInstanceState) {

AVOptions options = new AVOptions();
options.setInteger(AVOptions.KEY_VIDEO_DATA_CALLBACK, 1);
options.setInteger(AVOptions.KEY_MEDIACODEC, AVOptions.MEDIA_CODEC_AUTO);
options.setInteger(AVOptions.KEY_AUDIO_DATA_CALLBACK, 1);
options.setInteger(AVOptions.KEY_MEDIACODEC, AVOptions.MEDIA_CODEC_SW_DECODE);
mVideoTextureView.setAVOptions(options);
mVideoTextureView.setOnVideoFrameListener((data, size, width, height, format, ts) -> {
if (format == 0) {
Expand Down Expand Up @@ -116,16 +117,17 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onClick(View view) {
view.setEnabled(false);
switch (view.getId()) {
case R.id.play:
if (!mVideoTextureView.isPlaying()) {
mPlayButton.setEnabled(false);
mVideoTextureView.start();
mExternalMediaRecorder.start();
}
break;
case R.id.stop:
if (mVideoTextureView.isPlaying()) {
mStopButton.setEnabled(false);
mExternalMediaRecorder.stop();
if (mVideoTextureView != null) {
mVideoTextureView.stopPlayback();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void onClickCompose(View v) {
PLVideoEncodeSetting setting = new PLVideoEncodeSetting(this);
setting.setEncodingSizeLevel(getEncodingSizeLevel(mEncodingSizeLevelSpinner.getSelectedItemPosition()));
setting.setEncodingBitrate(getEncodingBitrateLevel(mEncodingBitrateLevelSpinner.getSelectedItemPosition()));
setting.setHWCodecEnabled(false);
PLDisplayMode displayMode = ((RadioButton) findViewById(R.id.fit_radio_btn)).isChecked() ? PLDisplayMode.FIT : PLDisplayMode.FULL;
mShortVideoComposer.composeImages(items, mAudioFilePath, true, Config.IMAGE_COMPOSE_FILE_PATH, displayMode, setting, mVideoSaveListener);
}
Expand Down Expand Up @@ -236,9 +237,9 @@ private void chooseFile(boolean isAudio) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_IMAGE_CODE) {
String selectedFilepath = GetPathFromUri.getPath(this, data.getData());
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
if (requestCode == REQUEST_IMAGE_CODE && data.getData() != null) {
String selectedFilepath = GetPathFromUri.getRealPathFromURI(this, data.getData());
Log.i(TAG, "Select file: " + selectedFilepath);
if (selectedFilepath != null && !"".equals(selectedFilepath)) {
PLComposeItem item = new PLComposeItem(selectedFilepath);
Expand All @@ -247,8 +248,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mImageListAdapter.notifyDataSetChanged();
ToastUtils.showShortToast("单击条目可以进行编辑,长按可以删除");
}
} else if (requestCode == REQUEST_AUDIO_CODE) {
mAudioFilePath = GetPathFromUri.getPath(this, data.getData());
} else if (requestCode == REQUEST_AUDIO_CODE && data.getData() != null) {
mAudioFilePath = GetPathFromUri.getRealPathFromURI(this, data.getData());
if (mAudioFilePath != null && !"".equals(mAudioFilePath)) {
String audioName = ImageListAdapter.getFileNameWithSuffix(mAudioFilePath);
if (!audioName.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ private void stateChange(boolean processing) {
}

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
if (requestCode == 100) {
final String selectedFilepath = GetPathFromUri.getPath(this, data.getData());
final String selectedFilepath = GetPathFromUri.getRealPathFromURI(this, data.getData());
Log.i(TAG, "Select file: " + selectedFilepath);
if (selectedFilepath != null && !"".equals(selectedFilepath)) {
showAddItemDialog(selectedFilepath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Environment;
import android.provider.Settings;
import android.view.View;

import com.qiniu.pili.droid.shortvideo.PLAuthenticationResultCallback;
Expand All @@ -24,6 +29,7 @@
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";

private ActivityResultLauncher<Intent> mActivityResultLauncher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -47,6 +53,12 @@ public void onAuthorizationResult(int result) {
}
}
});

mActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result.getResultCode() != RESULT_OK || result.getData() == null) {
ToastUtils.showShortToast("未获得全局存储权限");
}
});
}

@Override
Expand All @@ -60,6 +72,18 @@ private boolean isPermissionOK() {
if (!isPermissionOK) {
ToastUtils.showShortToast("Some permissions is not approved !!!");
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q && !Environment.isExternalStorageManager()) {
try {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
mActivityResultLauncher.launch(intent);
} catch (Exception exception) {
exception.printStackTrace();
}
return false;
}
return isPermissionOK;
}

Expand Down Expand Up @@ -106,7 +130,7 @@ public void onClickImageCompose(View v) {
}
}

public void onClickImageCompose2(View v) {
public void onClickImageComposeWithTransition(View v) {
if (isPermissionOK()) {
jumpToActivity(ImageComposeWithTransitionActivity.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
mInputFilePath = GetPathFromUri.getPath(this, data.getData());
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
mInputFilePath = GetPathFromUri.getRealPathFromURI(this, data.getData());
Log.i(TAG, "Select file: " + mInputFilePath);
if (mInputFilePath != null && !"".equals(mInputFilePath)) {
init(mInputFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public void onProgressUpdate(final float percentage) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
String selectedFilepath = GetPathFromUri.getPath(this, data.getData());
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
String selectedFilepath = GetPathFromUri.getRealPathFromURI(this, data.getData());
if (selectedFilepath == null || "".equals(selectedFilepath)) {
Log.i(TAG, "Select file error : can't be null or empty !");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ private void chooseVideoFile() {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
String selectedFilepath = GetPathFromUri.getPath(this, data.getData());
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
String selectedFilepath = GetPathFromUri.getRealPathFromURI(this, data.getData());
Log.i(TAG, "Select file: " + selectedFilepath);
if (selectedFilepath != null && !"".equals(selectedFilepath)) {
mVideoListAdapter.addVideoFile(selectedFilepath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -94,8 +95,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
mSrcVideoPath = GetPathFromUri.getPath(this, data.getData());
if (resultCode == Activity.RESULT_OK && data.getData() != null) {
mSrcVideoPath = GetPathFromUri.getRealPathFromURI(this, data.getData());
Log.i(TAG, "Select file: " + mSrcVideoPath);
if (mSrcVideoPath != null && !"".equals(mSrcVideoPath)) {
init();
Expand Down Expand Up @@ -193,6 +194,7 @@ private void initMediaInfo() {
private void initVideoPlayer() {
mPreview.setVideoPath(mSrcVideoPath);
mPreview.setOnCompletionListener(mediaPlayer -> play());
makeUpVideoViewSize();
play();
}

Expand Down Expand Up @@ -221,6 +223,41 @@ private void initFrameList() {
mFrameList.setLayoutManager(layoutManager);
}

private void makeUpVideoViewSize() {
int viewWidth, viewHeight, videoWidth, videoHeight, displayWidth, displayHeight;
float videoAspectRatio;
WindowManager windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(outMetrics);

viewWidth = outMetrics.widthPixels;
viewHeight = outMetrics.widthPixels;
Log.i(TAG, "View size: " + viewWidth + " × " + viewHeight);
if (mMediaFile.getVideoRotation() / 90 % 2 == 1) {
videoWidth = mMediaFile.getVideoHeight();
videoHeight = mMediaFile.getVideoWidth();
} else {
videoWidth = mMediaFile.getVideoWidth();
videoHeight = mMediaFile.getVideoHeight();
}
videoAspectRatio = (float) videoHeight / videoWidth;
Log.i(TAG, "Video size: " + videoWidth + " × " + videoHeight);

// view 的视图为一个正方形,宽高比为 1
if (1 > videoAspectRatio) {
displayWidth = viewWidth;
displayHeight = (int) ((float) viewWidth / videoWidth * videoHeight);
} else {
displayWidth = (int) ((float) viewHeight / videoHeight * videoWidth);
displayHeight = viewHeight;
}

RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mPreview.getLayoutParams();
layoutParams.width = displayWidth;
layoutParams.height = displayHeight;
mPreview.setLayoutParams(layoutParams);
}

private void resetData() {
mCurTrimNum = 0;
mPathList.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
mShortAudioRecorder.prepare(this, microphoneSetting, audioEncodeSetting, recordSetting);

mSectionProgressBar.setFirstPointTime(0);
mSectionProgressBar.setTotalTime(this, mShortVideoEditor.getDurationMs());
mSectionProgressBar.setTotalTime(mShortVideoEditor.getDurationMs());

mRecordBtn.setOnClickListener(v -> {
if (mIsRecordCompleted) {
Expand Down
Loading

0 comments on commit 09729a6

Please sign in to comment.