mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-30 19:04:54 +01:00
Fix broken video compression due to NPE in library
Library issue: https://github.com/natario1/Transcoder/issues/154 Possibly fixes https://github.com/vector-im/element-android/issues/4337 Also add some logging for failures.
This commit is contained in:
parent
54daee2798
commit
076820bb10
1
changelog.d/4353.bugfix
Normal file
1
changelog.d/4353.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix video compression before upload
|
@ -188,6 +188,9 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.let { videoCompressionResult ->
|
.let { videoCompressionResult ->
|
||||||
|
if (videoCompressionResult is VideoCompressionResult.CompressionFailed) {
|
||||||
|
videoCompressionResult.failure.printStackTrace()
|
||||||
|
}
|
||||||
when (videoCompressionResult) {
|
when (videoCompressionResult) {
|
||||||
is VideoCompressionResult.Success -> {
|
is VideoCompressionResult.Success -> {
|
||||||
val compressedFile = videoCompressionResult.compressedFile
|
val compressedFile = videoCompressionResult.compressedFile
|
||||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.content
|
|||||||
|
|
||||||
import com.otaliastudios.transcoder.Transcoder
|
import com.otaliastudios.transcoder.Transcoder
|
||||||
import com.otaliastudios.transcoder.TranscoderListener
|
import com.otaliastudios.transcoder.TranscoderListener
|
||||||
|
import com.otaliastudios.transcoder.source.FilePathDataSource
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@ -43,7 +44,16 @@ internal class VideoCompressor @Inject constructor(
|
|||||||
var result: Int = -1
|
var result: Int = -1
|
||||||
var failure: Throwable? = null
|
var failure: Throwable? = null
|
||||||
Transcoder.into(destinationFile.path)
|
Transcoder.into(destinationFile.path)
|
||||||
.addDataSource(videoFile.path)
|
.addDataSource(object : FilePathDataSource(videoFile.path) {
|
||||||
|
// https://github.com/natario1/Transcoder/issues/154
|
||||||
|
@Suppress("SENSELESS_COMPARISON") // Source is annotated as @NonNull, but can actually be null...
|
||||||
|
override fun isInitialized(): Boolean {
|
||||||
|
if (source == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return super.isInitialized()
|
||||||
|
}
|
||||||
|
})
|
||||||
.setListener(object : TranscoderListener {
|
.setListener(object : TranscoderListener {
|
||||||
override fun onTranscodeProgress(progress: Double) {
|
override fun onTranscodeProgress(progress: Double) {
|
||||||
Timber.d("Compressing: $progress%")
|
Timber.d("Compressing: $progress%")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user