feat: Add support for custom folder

This commit is contained in:
Myzel394 2023-12-29 21:53:48 +01:00
parent 4126dded6e
commit 4af8cd7318
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
3 changed files with 27 additions and 16 deletions

View File

@ -32,13 +32,17 @@ class AudioBatchesFolder(
): String {
return when (type) {
BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath
BatchType.CUSTOM -> FFmpegKitConfig.getSafParameterForWrite(
context,
customFolder!!.createFile(
"audio/${extension}",
getName(date, extension),
)!!.uri
)!!
BatchType.CUSTOM -> {
val name = getName(date, extension)
FFmpegKitConfig.getSafParameterForWrite(
context,
(customFolder!!.findFile(name) ?: customFolder.createFile(
"audio/${extension}",
getName(date, extension),
)!!).uri
)!!
}
}
}

View File

@ -1,8 +1,11 @@
package app.myzel394.alibi.helpers
import android.content.Context
import android.net.Uri
import android.util.Log
import androidx.documentfile.provider.DocumentFile
import com.arthenica.ffmpegkit.FFmpegKit
import com.arthenica.ffmpegkit.FFmpegKitConfig
import com.arthenica.ffmpegkit.ReturnCode
import kotlinx.coroutines.CompletableDeferred
import java.io.File
@ -66,7 +69,8 @@ class MediaConverter {
val listFile = createTempFile(inputFiles.joinToString("\n") { "file '$it'" })
val command =
" -f concat" +
"-protocol_whitelist saf,concat,content,file,subfile" +
" -f concat" +
" -safe 0" +
" -i ${listFile.absolutePath}" +
extraCommand +
@ -78,7 +82,6 @@ class MediaConverter {
command
) { session ->
runCatching {
listFile.delete()
}
if (!ReturnCode.isSuccess(session!!.returnCode)) {

View File

@ -28,13 +28,17 @@ class VideoBatchesFolder(
override fun getOutputFileForFFmpeg(date: LocalDateTime, extension: String): String {
return when (type) {
BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath
BatchType.CUSTOM -> FFmpegKitConfig.getSafParameterForWrite(
context,
customFolder!!.createFile(
"video/${extension}",
getName(date, extension),
)!!.uri
)!!
BatchType.CUSTOM -> {
val name = getName(date, extension)
FFmpegKitConfig.getSafParameterForWrite(
context,
(customFolder!!.findFile(name) ?: customFolder.createFile(
"video/${extension}",
getName(date, extension),
)!!).uri
)!!
}
}
}