Skip to content

Commit

Permalink
refactor: no longer overwrite existed gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroCBer committed Feb 5, 2024
1 parent 7b102af commit 0a8661f
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class RecyclerAdapterStickerList(private val act: MainActivity) :
val nameWithoutExt = remoteFile.name.substringBefore(".")
val id = nameWithoutExt.substringBefore("_")

// val outPathGif = "${syncedFolder}/${nameWithoutExt}.gif"

val existing = File(syncedFolder).listFiles()?.filter { it.name.startsWith(id) }
?: emptyList()

Expand All @@ -129,15 +127,13 @@ class RecyclerAdapterStickerList(private val act: MainActivity) :
"webm"->{
// encode to gif
val outPath = "${syncedFolder}/${nameWithoutExt}.gif"
if (File(outPath).exists()) {
File(outPath).delete()
}

val session = FFmpegKit.execute("-i ${remoteFile.absolutePath} -pix_fmt rgb24 ${outPath}")
if (session.returnCode.isValueSuccess) {
YLog.info("FFmpegKit: ${session.command} finished successfully")
} else {
YLog.error("FFmpegKit: ${session.command} failed with state ${session.state} and rc ${session.returnCode}")
if (!File(outPath).exists()) {
val session = FFmpegKit.execute("-i ${remoteFile.absolutePath} -pix_fmt rgb24 ${outPath}")
if (session.returnCode.isValueSuccess) {
YLog.info("FFmpegKit: ${session.command} finished successfully")
} else {
YLog.error("FFmpegKit: ${session.command} failed with state ${session.state} and rc ${session.returnCode}")
}
}
}
}
Expand Down

0 comments on commit 0a8661f

Please sign in to comment.