fix: Improve BatchesFolders; concatenate video files

This commit is contained in:
Myzel394 2023-11-28 17:48:03 +01:00
parent 89baa35ed7
commit 8c391a7504
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
3 changed files with 25 additions and 23 deletions

View File

@ -10,7 +10,7 @@ class AudioBatchesFolder(
override val context: Context, override val context: Context,
override val type: BatchType, override val type: BatchType,
override val customFolder: DocumentFile? = null, override val customFolder: DocumentFile? = null,
override val subfolderName: String = ".recordings", override val subfolderName: String = ".audio_recordings",
) : BatchesFolder( ) : BatchesFolder(
context, context,
type, type,
@ -37,23 +37,24 @@ class AudioBatchesFolder(
recordingStart: LocalDateTime, recordingStart: LocalDateTime,
extension: String, extension: String,
disableCache: Boolean, disableCache: Boolean,
) { ): String {
if (!disableCache && checkIfOutputAlreadyExists(recordingStart, extension)) {
return
}
val filePaths = getBatchesForFFmpeg()
val outputFile = getOutputFileForFFmpeg( val outputFile = getOutputFileForFFmpeg(
date = recordingStart, date = recordingStart,
extension = extension, extension = extension,
) )
if (disableCache || checkIfOutputAlreadyExists(recordingStart, extension)) {
val filePaths = getBatchesForFFmpeg()
MediaConverter.concatenateAudioFiles( MediaConverter.concatenateAudioFiles(
inputFiles = filePaths, inputFiles = filePaths,
outputFile = outputFile, outputFile = outputFile,
).await() ).await()
} }
return outputFile
}
companion object { companion object {
fun viaInternalFolder(context: Context): BatchesFolder { fun viaInternalFolder(context: Context): BatchesFolder {
return AudioBatchesFolder(context, BatchType.INTERNAL) return AudioBatchesFolder(context, BatchType.INTERNAL)

View File

@ -115,7 +115,7 @@ abstract class BatchesFolder(
recordingStart: LocalDateTime, recordingStart: LocalDateTime,
extension: String, extension: String,
disableCache: Boolean = false, disableCache: Boolean = false,
) ): String
fun exportFolderForSettings(): String { fun exportFolderForSettings(): String {
return when (type) { return when (type) {

View File

@ -10,7 +10,7 @@ class VideoBatchesFolder(
override val context: Context, override val context: Context,
override val type: BatchesFolder.BatchType, override val type: BatchesFolder.BatchType,
override val customFolder: DocumentFile? = null, override val customFolder: DocumentFile? = null,
override val subfolderName: String = ".recordings", override val subfolderName: String = ".video_recordings",
) : BatchesFolder( ) : BatchesFolder(
context, context,
type, type,
@ -34,23 +34,24 @@ class VideoBatchesFolder(
recordingStart: LocalDateTime, recordingStart: LocalDateTime,
extension: String, extension: String,
disableCache: Boolean disableCache: Boolean
) { ): String {
if (!disableCache && checkIfOutputAlreadyExists(recordingStart, extension)) {
return
}
val filePaths = getBatchesForFFmpeg()
val outputFile = getOutputFileForFFmpeg( val outputFile = getOutputFileForFFmpeg(
date = recordingStart, date = recordingStart,
extension = extension, extension = extension,
) )
MediaConverter.concatenateAudioFiles( if (disableCache || !checkIfOutputAlreadyExists(recordingStart, extension)) {
val filePaths = getBatchesForFFmpeg()
MediaConverter.concatenateVideoFiles(
inputFiles = filePaths, inputFiles = filePaths,
outputFile = outputFile, outputFile = outputFile,
).await() ).await()
} }
return outputFile
}
companion object { companion object {
fun viaInternalFolder(context: Context): BatchesFolder { fun viaInternalFolder(context: Context): BatchesFolder {
return VideoBatchesFolder(context, BatchType.INTERNAL) return VideoBatchesFolder(context, BatchType.INTERNAL)