Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4353.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix video compression before upload
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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%")
Expand Down