fix(media_downloader): two images overlay merge

This commit is contained in:
rhunk
2023-09-06 23:02:11 +02:00
parent 2cf172e597
commit 7924d5a445
3 changed files with 9 additions and 6 deletions

View File

@ -380,14 +380,15 @@ class DownloadProcessor (
if (shouldMergeOverlay) {
assert(downloadedMedias.size == 2)
val media = downloadedMedias.values.first { it.fileType.isVideo }
val overlayMedia = downloadedMedias.values.first { it.fileType.isImage }
//TODO: convert "mp4 images" into real images
val media = downloadedMedias.entries.first { !it.key.isOverlay }.value
val overlayMedia = downloadedMedias.entries.first { it.key.isOverlay }.value
val renamedMedia = renameFromFileType(media.file, media.fileType)
val renamedOverlayMedia = renameFromFileType(overlayMedia.file, overlayMedia.fileType)
val mergedOverlay: File = File.createTempFile("merged", "." + media.fileType.fileExtension)
val mergedOverlay: File = File.createTempFile("merged", ".mp4")
runCatching {
callbackOnProgress(translation.format("download_toast", "path" to media.file.nameWithoutExtension))
callbackOnProgress(translation.format("processing_toast", "path" to media.file.nameWithoutExtension))
downloadObjectObject.downloadStage = DownloadStage.MERGING
ffmpegProcessor.execute(FFMpegProcessor.Request(

View File

@ -7,6 +7,7 @@ data class InputMedia(
val type: DownloadMediaType,
val encryption: MediaEncryptionKeyPair? = null,
val messageContentType: String? = null,
val isOverlay: Boolean = false,
)
class DownloadRequest(

View File

@ -199,7 +199,8 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
overlay = InputMedia(
overlayReference,
DownloadMediaType.fromUri(Uri.parse(overlayReference)),
overlay.encryption?.toKeyPair()
overlay.encryption?.toKeyPair(),
isOverlay = true
)
)
return
@ -372,7 +373,7 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp
mediaAuthor = storyName
).downloadDashMedia(playlistUrl, 0, null)
}
setPositiveButton("Download") { dialog, which ->
setPositiveButton("Download") { _, _ ->
val groups = mutableListOf<MutableList<SnapChapterInfo>>()
var currentGroup = mutableListOf<SnapChapterInfo>()
var lastChapterIndex = -1