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,21 +37,22 @@ 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,
) )
MediaConverter.concatenateAudioFiles( if (disableCache || checkIfOutputAlreadyExists(recordingStart, extension)) {
inputFiles = filePaths, val filePaths = getBatchesForFFmpeg()
outputFile = outputFile,
).await() MediaConverter.concatenateAudioFiles(
inputFiles = filePaths,
outputFile = outputFile,
).await()
}
return outputFile
} }
companion object { companion object {

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,21 +34,22 @@ 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)) {
inputFiles = filePaths, val filePaths = getBatchesForFFmpeg()
outputFile = outputFile,
).await() MediaConverter.concatenateVideoFiles(
inputFiles = filePaths,
outputFile = outputFile,
).await()
}
return outputFile
} }
companion object { companion object {