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 { ): String {
return when (type) { return when (type) {
BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath
BatchType.CUSTOM -> FFmpegKitConfig.getSafParameterForWrite( BatchType.CUSTOM -> {
context, val name = getName(date, extension)
customFolder!!.createFile(
"audio/${extension}", FFmpegKitConfig.getSafParameterForWrite(
getName(date, extension), context,
)!!.uri (customFolder!!.findFile(name) ?: customFolder.createFile(
)!! "audio/${extension}",
getName(date, extension),
)!!).uri
)!!
}
} }
} }

View File

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

View File

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