Merge pull request #4353 from SpiritCroc/video-compression
Fix broken video compression due to NPE in library
This commit is contained in:
commit
3760401b10
|
@ -0,0 +1 @@
|
|||
Fix video compression before upload
|
|
@ -214,8 +214,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||
.also { filesToDelete.add(it) }
|
||||
}
|
||||
VideoCompressionResult.CompressionNotNeeded,
|
||||
VideoCompressionResult.CompressionCancelled,
|
||||
VideoCompressionResult.CompressionCancelled -> {
|
||||
workingFile
|
||||
}
|
||||
is VideoCompressionResult.CompressionFailed -> {
|
||||
Timber.e(videoCompressionResult.failure, "Video compression failed")
|
||||
workingFile
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.content
|
|||
|
||||
import com.otaliastudios.transcoder.Transcoder
|
||||
import com.otaliastudios.transcoder.TranscoderListener
|
||||
import com.otaliastudios.transcoder.source.FilePathDataSource
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -43,7 +44,16 @@ internal class VideoCompressor @Inject constructor(
|
|||
var result: Int = -1
|
||||
var failure: Throwable? = null
|
||||
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 {
|
||||
override fun onTranscodeProgress(progress: Double) {
|
||||
Timber.d("Compressing: $progress%")
|
||||
|
|
Loading…
Reference in New Issue