|
@@ -9,6 +9,7 @@ import android.os.Environment
|
|
|
import android.os.Handler
|
|
import android.os.Handler
|
|
|
import android.os.Message
|
|
import android.os.Message
|
|
|
import android.text.TextUtils
|
|
import android.text.TextUtils
|
|
|
|
|
+import android.util.Log
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
|
import cn.i2edu.dubbing_lib.audioUtils.AudioDecoder
|
|
import cn.i2edu.dubbing_lib.audioUtils.AudioDecoder
|
|
@@ -22,9 +23,7 @@ import cn.i2edu.dubbing_lib.bean.VideoData
|
|
|
import cn.i2edu.dubbing_lib.callback.MixinHandlerCallback
|
|
import cn.i2edu.dubbing_lib.callback.MixinHandlerCallback
|
|
|
import cn.i2edu.dubbing_lib.util.PausableThreadPool
|
|
import cn.i2edu.dubbing_lib.util.PausableThreadPool
|
|
|
import com.alibaba.fastjson.JSON
|
|
import com.alibaba.fastjson.JSON
|
|
|
-import cn.i2edu.dubbing_lib.listener.DownloadListener
|
|
|
|
|
import cn.i2edu.dubbing_lib.util.AudioEvaluatorUtil
|
|
import cn.i2edu.dubbing_lib.util.AudioEvaluatorUtil
|
|
|
-import cn.i2edu.dubbing_lib.util.DownloadUtil
|
|
|
|
|
import cn.i2edu.dubbing_lib.util.EvaluatorCallBack
|
|
import cn.i2edu.dubbing_lib.util.EvaluatorCallBack
|
|
|
import com.iflytek.cloud.EvaluatorResult
|
|
import com.iflytek.cloud.EvaluatorResult
|
|
|
import com.iflytek.cloud.SpeechConstant
|
|
import com.iflytek.cloud.SpeechConstant
|
|
@@ -49,22 +48,20 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
private var timer: Timer? = null
|
|
private var timer: Timer? = null
|
|
|
private val pausableThreadPool: PausableThreadPool = PausableThreadPool(1)
|
|
private val pausableThreadPool: PausableThreadPool = PausableThreadPool(1)
|
|
|
private val mixinHandler: MixinHandler = MixinHandler(this)
|
|
private val mixinHandler: MixinHandler = MixinHandler(this)
|
|
|
- private var mixinResult: MethodChannel.Result? = null
|
|
|
|
|
|
|
+ private var mixinResult: Result? = null
|
|
|
private var videoData: VideoData? = null
|
|
private var videoData: VideoData? = null
|
|
|
private var videoAudioMixer: VideoAudioMixer? = null
|
|
private var videoAudioMixer: VideoAudioMixer? = null
|
|
|
private val Tag: String = "DubbingPlugin"
|
|
private val Tag: String = "DubbingPlugin"
|
|
|
|
|
+ // mix in 时用到的目录
|
|
|
|
|
+ private var pathBgmDecodeDir: String? = null
|
|
|
|
|
+ private var pathBgmRecordSyncDir: String? = null
|
|
|
|
|
+ private var pathBgmRecordDecodeSyncDir: String? = null
|
|
|
|
|
+ private var pathVideoMixinDir: String? = null
|
|
|
|
|
|
|
|
companion object {
|
|
companion object {
|
|
|
|
|
|
|
|
private lateinit var channel: MethodChannel
|
|
private lateinit var channel: MethodChannel
|
|
|
val CHANNEL_NAME = "cn.hwwwwh.flutter.plugins/DubbingPlugin"
|
|
val CHANNEL_NAME = "cn.hwwwwh.flutter.plugins/DubbingPlugin"
|
|
|
- val PATH_AUDIO = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record/"
|
|
|
|
|
- val PATH_AUDIO_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record_decode/"
|
|
|
|
|
- val PATH_AUDIO_EVALUATOR_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record_evaluator_decode/"
|
|
|
|
|
- val PATH_BGM_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_decode/"
|
|
|
|
|
- val PATH_BGM_RECORD_SYN = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_record_syn/"
|
|
|
|
|
- val PATH_BGM_RECORD_SYN_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_record_syn_decode/"
|
|
|
|
|
- val PATH_VIDEO_MIXIN = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_video_mixin/"
|
|
|
|
|
private val BGM_DOWNLOAD_FINISHED = 0X3999
|
|
private val BGM_DOWNLOAD_FINISHED = 0X3999
|
|
|
private val AUDIO_SYN_FINISHED = 0X4001
|
|
private val AUDIO_SYN_FINISHED = 0X4001
|
|
|
private val AUDIO_MIX_VIDIO_FINISHED = 0X4002
|
|
private val AUDIO_MIX_VIDIO_FINISHED = 0X4002
|
|
@@ -106,16 +103,16 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
activity.window.decorView.systemUiVisibility = activity.window.decorView.systemUiVisibility.or(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
|
activity.window.decorView.systemUiVisibility = activity.window.decorView.systemUiVisibility.or(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- "downLoadVideo" -> {
|
|
|
|
|
- downloadVideo(call.argument<String>("url")!!, result)
|
|
|
|
|
- }
|
|
|
|
|
"startRecord" -> {
|
|
"startRecord" -> {
|
|
|
val duration = call.argument<Int>("duration")!!
|
|
val duration = call.argument<Int>("duration")!!
|
|
|
val fileName = call.argument<String>("fileName")!!
|
|
val fileName = call.argument<String>("fileName")!!
|
|
|
val index = call.argument<Int>("index")!!
|
|
val index = call.argument<Int>("index")!!
|
|
|
val en = call.argument<String>("content")!!
|
|
val en = call.argument<String>("content")!!
|
|
|
|
|
+ val pathAudio = call.argument<String>("pathAudio")!!
|
|
|
|
|
+ val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
|
|
|
|
|
+ val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
|
|
|
// 开启录音
|
|
// 开启录音
|
|
|
- initMediaRecorder(index, duration, fileName, en, result)
|
|
|
|
|
|
|
+ initMediaRecorder(pathAudio, pathAudioDecode, pathEvaluatorDecode, index, duration, fileName, en, result)
|
|
|
}
|
|
}
|
|
|
"playRecordAudio" -> {
|
|
"playRecordAudio" -> {
|
|
|
val fileName = call.argument<String>("fileName")!!
|
|
val fileName = call.argument<String>("fileName")!!
|
|
@@ -132,8 +129,10 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
try {
|
|
try {
|
|
|
// 取得 video id, 根据前缀进行删除操作
|
|
// 取得 video id, 根据前缀进行删除操作
|
|
|
val videoId = call.argument<String>("videoId")!!
|
|
val videoId = call.argument<String>("videoId")!!
|
|
|
- deleteFileWithPrefix(videoId, PATH_AUDIO)
|
|
|
|
|
- deleteFileWithPrefix(videoId, PATH_AUDIO_DECODE)
|
|
|
|
|
|
|
+ val pathAudio = call.argument<String>("pathAudio")!!
|
|
|
|
|
+ val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
|
|
|
|
|
+ deleteFileWithPrefix(videoId, pathAudio)
|
|
|
|
|
+ deleteFileWithPrefix(videoId, pathAudioDecode)
|
|
|
result.success(true)
|
|
result.success(true)
|
|
|
} catch (e: Exception){
|
|
} catch (e: Exception){
|
|
|
e.printStackTrace()
|
|
e.printStackTrace()
|
|
@@ -144,7 +143,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
try {
|
|
try {
|
|
|
// 取得 video id, 根据前缀进行查找操作
|
|
// 取得 video id, 根据前缀进行查找操作
|
|
|
val videoId = call.argument<String>("videoId")!!
|
|
val videoId = call.argument<String>("videoId")!!
|
|
|
- val map = getExistCache(videoId)
|
|
|
|
|
|
|
+ val pathAudio = call.argument<String>("pathAudio")!!
|
|
|
|
|
+ val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
|
|
|
|
|
+ val map = getExistCache(videoId, pathAudio, pathAudioDecode)
|
|
|
result.success(map)
|
|
result.success(map)
|
|
|
} catch (e: Exception){
|
|
} catch (e: Exception){
|
|
|
e.printStackTrace()
|
|
e.printStackTrace()
|
|
@@ -161,6 +162,12 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
audioDecodePaths = call.argument<List<String>>("audioDecodePaths")!!,
|
|
audioDecodePaths = call.argument<List<String>>("audioDecodePaths")!!,
|
|
|
videoPath = call.argument<String>("videoPath")!!
|
|
videoPath = call.argument<String>("videoPath")!!
|
|
|
)
|
|
)
|
|
|
|
|
+ videoData!!.bgmPath = call.argument<String>("bgmPath")!!
|
|
|
|
|
+ pathBgmDecodeDir = call.argument<String>("pathBgmDecode")!!
|
|
|
|
|
+ pathBgmRecordSyncDir = call.argument<String>("pathBgmRecordSync")!!
|
|
|
|
|
+ pathBgmRecordDecodeSyncDir = call.argument<String>("pathBgmRecordDecodeSync")!!
|
|
|
|
|
+ pathVideoMixinDir = call.argument<String>("pathVideoMixin")!!
|
|
|
|
|
+
|
|
|
mixinResult = result
|
|
mixinResult = result
|
|
|
startMixinAudio()
|
|
startMixinAudio()
|
|
|
} catch (e: Exception){
|
|
} catch (e: Exception){
|
|
@@ -172,40 +179,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun downloadVideo(url: String, result: MethodChannel.Result) {
|
|
|
|
|
- val downloadUtil = DownloadUtil()
|
|
|
|
|
- downloadUtil.downloadFile(url, object : DownloadListener {
|
|
|
|
|
- override fun onStart() {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onProgress(progress: Int) {
|
|
|
|
|
- activity.runOnUiThread {
|
|
|
|
|
- channel.invokeMethod("downloadUpdate", mapOf("progress" to progress))
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onFinish(localPath: String) {
|
|
|
|
|
- activity.runOnUiThread {
|
|
|
|
|
- result.success(localPath)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onFailure() {
|
|
|
|
|
- activity.runOnUiThread {
|
|
|
|
|
- result.error("10002", "下载存储错误", null)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private fun initMediaRecorder(index: Int, duration: Int, fileName: String, en: String, result: MethodChannel.Result) {
|
|
|
|
|
|
|
+ private fun initMediaRecorder(pathAudio: String, pathAudioDecode: String, pathEvaluatorDecode: String,
|
|
|
|
|
+ index: Int, duration: Int, fileName: String, en: String, result: Result) {
|
|
|
// create file
|
|
// create file
|
|
|
- val file = File(PATH_AUDIO)
|
|
|
|
|
- if (!file.exists()) {
|
|
|
|
|
- file.mkdirs()
|
|
|
|
|
- }
|
|
|
|
|
stopRecord()
|
|
stopRecord()
|
|
|
// config media recorder
|
|
// config media recorder
|
|
|
if (mediaRecorder == null) {
|
|
if (mediaRecorder == null) {
|
|
@@ -218,12 +194,12 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
mediaRecorder?.setAudioSamplingRate(44100)// 采样率
|
|
mediaRecorder?.setAudioSamplingRate(44100)// 采样率
|
|
|
}
|
|
}
|
|
|
// start record
|
|
// start record
|
|
|
- startRecord(index, duration, fileName, en, result)
|
|
|
|
|
|
|
+ startRecord(pathAudio, pathAudioDecode, pathEvaluatorDecode, index, duration, fileName, en, result)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun startRecord(index: Int, duration: Int, fileName: String, en: String, result: MethodChannel.Result) {
|
|
|
|
|
|
|
+ private fun startRecord(pathAudio: String, pathAudioDecode: String, pathEvaluatorDecode: String, index: Int, duration: Int, fileName: String, en: String, result: Result) {
|
|
|
if (mediaRecorder == null) return
|
|
if (mediaRecorder == null) return
|
|
|
- val filePath = PATH_AUDIO + fileName
|
|
|
|
|
|
|
+ val filePath = pathAudio + fileName
|
|
|
try {
|
|
try {
|
|
|
mediaRecorder?.setOutputFile(filePath)
|
|
mediaRecorder?.setOutputFile(filePath)
|
|
|
mediaRecorder?.prepare()
|
|
mediaRecorder?.prepare()
|
|
@@ -258,11 +234,11 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
stopRecord()
|
|
stopRecord()
|
|
|
// 解码音频
|
|
// 解码音频
|
|
|
Thread {
|
|
Thread {
|
|
|
- decodeRecord(index, fileName, filePath)
|
|
|
|
|
|
|
+ decodeRecord(pathAudioDecode, index, fileName, filePath)
|
|
|
}.start()
|
|
}.start()
|
|
|
// 评测音频
|
|
// 评测音频
|
|
|
Thread {
|
|
Thread {
|
|
|
- evaluatorRecord(index, filePath, en)
|
|
|
|
|
|
|
+ evaluatorRecord(pathEvaluatorDecode, index, filePath, en)
|
|
|
}.start()
|
|
}.start()
|
|
|
}
|
|
}
|
|
|
break
|
|
break
|
|
@@ -275,10 +251,10 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun evaluatorRecord(index: Int, recordPath: String, en: String) {
|
|
|
|
|
- val dir = File(PATH_AUDIO_EVALUATOR_DECODE)
|
|
|
|
|
|
|
+ private fun evaluatorRecord(pathEvaluatorDecode: String, index: Int, recordPath: String, en: String) {
|
|
|
|
|
+ val dir = File(pathEvaluatorDecode)
|
|
|
if (!dir.exists()) dir.mkdirs()
|
|
if (!dir.exists()) dir.mkdirs()
|
|
|
- val decodePath = PATH_AUDIO_EVALUATOR_DECODE + "/" + UUID.randomUUID().toString() + ".pcm"
|
|
|
|
|
|
|
+ val decodePath = pathEvaluatorDecode + UUID.randomUUID().toString() + ".pcm"
|
|
|
AudioEvaluatorUtil.getInstance(context = activity.applicationContext)
|
|
AudioEvaluatorUtil.getInstance(context = activity.applicationContext)
|
|
|
.setEvaluatorCallBack(object : EvaluatorCallBack {
|
|
.setEvaluatorCallBack(object : EvaluatorCallBack {
|
|
|
override fun onResult(result: EvaluatorResult) {
|
|
override fun onResult(result: EvaluatorResult) {
|
|
@@ -321,8 +297,8 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
?.startEvaluator(en, recordPath, decodePath)
|
|
?.startEvaluator(en, recordPath, decodePath)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun decodeRecord(index: Int, fileName: String, recordPath: String) {
|
|
|
|
|
- val decodePath = doDecode(fileName, recordPath, PATH_AUDIO_DECODE)
|
|
|
|
|
|
|
+ private fun decodeRecord(pathAudioDecode: String, index: Int, fileName: String, recordPath: String) {
|
|
|
|
|
+ val decodePath = doDecode(fileName, recordPath, pathAudioDecode)
|
|
|
if (decodePath != null && File(decodePath).exists()) {
|
|
if (decodePath != null && File(decodePath).exists()) {
|
|
|
// 解码成功
|
|
// 解码成功
|
|
|
activity.runOnUiThread {
|
|
activity.runOnUiThread {
|
|
@@ -356,7 +332,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun playRecord(fileName: String, result: MethodChannel.Result) {
|
|
|
|
|
|
|
+ private fun playRecord(fileName: String, result: Result) {
|
|
|
resetMediaPlayer()
|
|
resetMediaPlayer()
|
|
|
mediaPlayer = MediaPlayer()
|
|
mediaPlayer = MediaPlayer()
|
|
|
mediaPlayer?.setDataSource(fileName)
|
|
mediaPlayer?.setDataSource(fileName)
|
|
@@ -395,17 +371,17 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Throws(Exception::class)
|
|
@Throws(Exception::class)
|
|
|
- private fun getExistCache(video: String): Map<Int, String> {
|
|
|
|
|
|
|
+ private fun getExistCache(video: String, pathAudio: String, pathAudioDecode: String): Map<Int, String> {
|
|
|
val map = hashMapOf<Int, String>()
|
|
val map = hashMapOf<Int, String>()
|
|
|
|
|
|
|
|
// 取得所有文件
|
|
// 取得所有文件
|
|
|
- val file = File(PATH_AUDIO)
|
|
|
|
|
|
|
+ val file = File(pathAudio)
|
|
|
if (!file.exists()) return map
|
|
if (!file.exists()) return map
|
|
|
val files = file.listFiles()
|
|
val files = file.listFiles()
|
|
|
if (files == null || files.isEmpty()) return map
|
|
if (files == null || files.isEmpty()) return map
|
|
|
|
|
|
|
|
// 取得所有文件(这里取decode的文件)
|
|
// 取得所有文件(这里取decode的文件)
|
|
|
- val decodeFile = File(PATH_AUDIO_DECODE)
|
|
|
|
|
|
|
+ val decodeFile = File(pathAudioDecode)
|
|
|
if (!decodeFile.exists()) return map
|
|
if (!decodeFile.exists()) return map
|
|
|
val decodeFiles = decodeFile.listFiles()
|
|
val decodeFiles = decodeFile.listFiles()
|
|
|
if (decodeFiles == null || decodeFiles.isEmpty()) return map
|
|
if (decodeFiles == null || decodeFiles.isEmpty()) return map
|
|
@@ -474,41 +450,18 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun startMixinAudio() {
|
|
private fun startMixinAudio() {
|
|
|
- pausableThreadPool.execute {
|
|
|
|
|
- // 下载背景音乐
|
|
|
|
|
- val downloadUtil = DownloadUtil()
|
|
|
|
|
- downloadUtil.downloadBGMFile(videoData!!.bgmUrl, object: DownloadListener {
|
|
|
|
|
- override fun onStart() {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onProgress(progress: Int) {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onFinish(localPath: String) {
|
|
|
|
|
- // 下载成功传回bgm地址
|
|
|
|
|
- activity.runOnUiThread {
|
|
|
|
|
- channel.invokeMethod("bgmAudioPath", mapOf("bgmPath" to localPath))
|
|
|
|
|
- videoData!!.bgmPath = localPath
|
|
|
|
|
- // step2 解码背景音乐
|
|
|
|
|
- val message = Message.obtain()
|
|
|
|
|
- message.what = BGM_DOWNLOAD_FINISHED
|
|
|
|
|
- mixinHandler.sendMessage(message)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override fun onFailure() {
|
|
|
|
|
- activity.runOnUiThread {
|
|
|
|
|
- mixinResult?.error("1005", "down load bgm failed", "")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ activity.runOnUiThread {
|
|
|
|
|
+ // step2 解码背景音乐
|
|
|
|
|
+ val message = Message.obtain()
|
|
|
|
|
+ message.what = BGM_DOWNLOAD_FINISHED
|
|
|
|
|
+ mixinHandler.sendMessage(message)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun decodeBgmAudio(fileName:String, localPath: String) {
|
|
private fun decodeBgmAudio(fileName:String, localPath: String) {
|
|
|
if (TextUtils.isEmpty(localPath)) return
|
|
if (TextUtils.isEmpty(localPath)) return
|
|
|
pausableThreadPool.execute {
|
|
pausableThreadPool.execute {
|
|
|
- val decodedPath = doDecode(fileName, localPath, PATH_BGM_DECODE)
|
|
|
|
|
|
|
+ val decodedPath = doDecode(fileName, localPath, pathBgmDecodeDir!!)
|
|
|
videoData?.decodeBgmPath = decodedPath
|
|
videoData?.decodeBgmPath = decodedPath
|
|
|
// step3 背景音乐与录音合成
|
|
// step3 背景音乐与录音合成
|
|
|
val message = Message.obtain()
|
|
val message = Message.obtain()
|
|
@@ -519,7 +472,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
|
|
|
|
|
private fun syncAudios() {
|
|
private fun syncAudios() {
|
|
|
// 合成背景音乐和录音 (从尾部开始)
|
|
// 合成背景音乐和录音 (从尾部开始)
|
|
|
- val fileDIR = File(PATH_BGM_RECORD_SYN)
|
|
|
|
|
|
|
+ val fileDIR = File(pathBgmRecordSyncDir)
|
|
|
if (!fileDIR.exists()) {
|
|
if (!fileDIR.exists()) {
|
|
|
fileDIR.mkdirs()
|
|
fileDIR.mkdirs()
|
|
|
}
|
|
}
|
|
@@ -556,9 +509,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
val accEncoder = AudioEncoder
|
|
val accEncoder = AudioEncoder
|
|
|
.createAccEncoder(videoData?.decodeAsyncBgmPath)
|
|
.createAccEncoder(videoData?.decodeAsyncBgmPath)
|
|
|
// String finalMixPath = FileBiz.get_temp_recorders_dir() + "/" + UUID.randomUUID() + ".mp4";
|
|
// String finalMixPath = FileBiz.get_temp_recorders_dir() + "/" + UUID.randomUUID() + ".mp4";
|
|
|
- val file = File(PATH_BGM_RECORD_SYN_DECODE)
|
|
|
|
|
|
|
+ val file = File(pathBgmRecordDecodeSyncDir)
|
|
|
if (!file.exists()) file.mkdirs()
|
|
if (!file.exists()) file.mkdirs()
|
|
|
- val finalMixPath = PATH_BGM_RECORD_SYN_DECODE + "mixinDecode.aac"
|
|
|
|
|
|
|
+ val finalMixPath = pathBgmRecordDecodeSyncDir + "mixinDecode.aac"
|
|
|
val isEncodeFinished = !TextUtils.isEmpty(accEncoder.encodeToFile(finalMixPath))
|
|
val isEncodeFinished = !TextUtils.isEmpty(accEncoder.encodeToFile(finalMixPath))
|
|
|
if (!isEncodeFinished) {
|
|
if (!isEncodeFinished) {
|
|
|
activity.runOnUiThread{
|
|
activity.runOnUiThread{
|
|
@@ -580,7 +533,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
videoAudioMixer?.setListener(object: VideoAudioMixer.VideoAudioMixListener {
|
|
videoAudioMixer?.setListener(object: VideoAudioMixer.VideoAudioMixListener {
|
|
|
override fun mixSuccess() {
|
|
override fun mixSuccess() {
|
|
|
- videoData?.mixVideoPath = PATH_VIDEO_MIXIN + "${videoData?.videoId}_mix.mp4"
|
|
|
|
|
|
|
+ videoData?.mixVideoPath = pathVideoMixinDir + "${videoData?.videoId}_mix.mp4"
|
|
|
val msg = Message()
|
|
val msg = Message()
|
|
|
msg.what = AUDIO_MIX_VIDIO_FINISHED
|
|
msg.what = AUDIO_MIX_VIDIO_FINISHED
|
|
|
mixinHandler.sendMessage(msg)
|
|
mixinHandler.sendMessage(msg)
|
|
@@ -593,7 +546,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
videoAudioMixer?.mux(videoData?.encodeAudioWithBgmPath, videoData?.videoPath,
|
|
videoAudioMixer?.mux(videoData?.encodeAudioWithBgmPath, videoData?.videoPath,
|
|
|
- "${videoData?.videoId}_mix.mp4", PATH_VIDEO_MIXIN)
|
|
|
|
|
|
|
+ "${videoData?.videoId}_mix.mp4", pathVideoMixinDir)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|