Merge branch 'develop' into feature/fga/fix_media_pre_processing
This commit is contained in:
commit
15ef9abed6
10 changed files with 31 additions and 20 deletions
|
|
@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.onEach
|
|||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.time.Duration
|
||||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
|
|
@ -192,7 +193,7 @@ class AndroidMediaPreProcessor @Inject constructor(
|
|||
return MediaMetadataRetriever().runAndRelease {
|
||||
setDataSource(context, Uri.fromFile(file))
|
||||
val info = AudioInfo(
|
||||
duration = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L,
|
||||
duration = extractDuration(),
|
||||
size = file.length(),
|
||||
mimeType = mimeType,
|
||||
)
|
||||
|
|
@ -225,7 +226,7 @@ class AndroidMediaPreProcessor @Inject constructor(
|
|||
MediaMetadataRetriever().runAndRelease {
|
||||
setDataSource(context, Uri.fromFile(file))
|
||||
VideoInfo(
|
||||
duration = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L,
|
||||
duration = extractDuration(),
|
||||
width = extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)?.toLong() ?: 0L,
|
||||
height = extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)?.toLong() ?: 0L,
|
||||
mimetype = mimeType,
|
||||
|
|
@ -253,3 +254,9 @@ fun ImageCompressionResult.toImageInfo(mimeType: String, thumbnailResult: Thumbn
|
|||
thumbnailSource = null,
|
||||
blurhash = thumbnailResult.blurhash,
|
||||
)
|
||||
|
||||
private fun MediaMetadataRetriever.extractDuration(): Duration {
|
||||
val durationInMs = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L
|
||||
return Duration.ofMillis(durationInMs)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue