Open loyilin opened 2 years ago
原来使用的是3.1.1,升级最新SDK还是不行,错误码6,对应ERROR_SETUP_VIDEO_ENCODER_FAILED 我使用裁剪后再压缩也一样,目前只发现这一个视频不行
private fun transcode(timerPath: String) { mProcessingDialog!!.setMessage(getString(R.string.video_compression)) mProcessingDialog!!.show() val plMediaFile = PLMediaFile(timerPath) videoTranscodePath = Config.getVideoTranscodePath() mShortVideoTranscoding = PLShortVideoTranscoder(this@QNVideoTrimActivity, timerPath, videoTranscodePath) mShortVideoTranscoding?.transcode(plMediaFile.videoWidth, plMediaFile.videoHeight, plMediaFile.videoBitrate / 1000, object : PLVideoSaveListener { override fun onSaveVideoSuccess(path: String) { //视频转码 mIsTrimmingVideo = false runOnUiThread { val plMediaFile = PLMediaFile(path) if (mProcessingDialog != null && mProcessingDialog!!.isShowing && !isFinishing && !isDestroyed) { mProcessingDialog!!.isIndeterminate = true mProcessingDialog!!.dismiss() } //转码完成返回目标页面 returnHandlerResult(path, plMediaFile.durationMs) } }
override fun onSaveVideoFailed(errorCode: Int) { mIsTrimmingVideo = false runOnUiThread { if (mProcessingDialog != null && mProcessingDialog!!.isShowing && !isFinishing && !isDestroyed) { mProcessingDialog!!.isIndeterminate = true mProcessingDialog!!.dismiss() } ToastUtils.showLongToast(getString(R.string.video_compression_failed)) } } override fun onSaveVideoCanceled() { runOnUiThread { mIsTrimmingVideo = false if (mProcessingDialog != null && mProcessingDialog!!.isShowing && !isFinishing && !isDestroyed) { mProcessingDialog!!.isIndeterminate = true mProcessingDialog!!.dismiss() } } } override fun onProgressUpdate(percentage: Float) { runOnUiThread { mProcessingDialog!!.setMessage(String.format(getString(R.string.compressing), (100 * percentage).toInt())) } } }) }
看报错是配置编码器出了问题,可能是由于该手机无法支持这个编码配置
@ShaoLongFei 有什么建议吗
这个和具体的机型和视频源相关,比如一个手机它无法支持编码 4K 视频,那你给它 4K 的视频就无法处理,受手机硬件限制
已支持软编码,硬编码失败也会自动切换为软编码重试
原来使用的是3.1.1,升级最新SDK还是不行,错误码6,对应ERROR_SETUP_VIDEO_ENCODER_FAILED 我使用裁剪后再压缩也一样,目前只发现这一个视频不行
private fun transcode(timerPath: String) { mProcessingDialog!!.setMessage(getString(R.string.video_compression)) mProcessingDialog!!.show() val plMediaFile = PLMediaFile(timerPath) videoTranscodePath = Config.getVideoTranscodePath() mShortVideoTranscoding = PLShortVideoTranscoder(this@QNVideoTrimActivity, timerPath, videoTranscodePath) mShortVideoTranscoding?.transcode(plMediaFile.videoWidth, plMediaFile.videoHeight, plMediaFile.videoBitrate / 1000, object : PLVideoSaveListener { override fun onSaveVideoSuccess(path: String) { //视频转码 mIsTrimmingVideo = false runOnUiThread { val plMediaFile = PLMediaFile(path) if (mProcessingDialog != null && mProcessingDialog!!.isShowing && !isFinishing && !isDestroyed) { mProcessingDialog!!.isIndeterminate = true mProcessingDialog!!.dismiss() } //转码完成返回目标页面 returnHandlerResult(path, plMediaFile.durationMs) } }