mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
fix: Remove ForceExactMaxDuration
This commit is contained in:
parent
0364a79dcb
commit
703e783193
@ -76,7 +76,6 @@ data class RecordingInformation(
|
|||||||
val maxDuration: Long,
|
val maxDuration: Long,
|
||||||
val intervalDuration: Long,
|
val intervalDuration: Long,
|
||||||
val fileExtension: String,
|
val fileExtension: String,
|
||||||
val forceExactMaxDuration: Boolean,
|
|
||||||
) {
|
) {
|
||||||
val hasRecordingsAvailable
|
val hasRecordingsAvailable
|
||||||
get() = File(folderPath).listFiles()?.isNotEmpty() ?: false
|
get() = File(folderPath).listFiles()?.isNotEmpty() ?: false
|
||||||
@ -88,7 +87,6 @@ data class AudioRecorderSettings(
|
|||||||
val maxDuration: Long = 30 * 60 * 1000L,
|
val maxDuration: Long = 30 * 60 * 1000L,
|
||||||
// 60 seconds
|
// 60 seconds
|
||||||
val intervalDuration: Long = 60 * 1000L,
|
val intervalDuration: Long = 60 * 1000L,
|
||||||
val forceExactMaxDuration: Boolean = true,
|
|
||||||
// 320 Kbps
|
// 320 Kbps
|
||||||
val bitRate: Int = 320000,
|
val bitRate: Int = 320000,
|
||||||
val samplingRate: Int? = null,
|
val samplingRate: Int? = null,
|
||||||
@ -238,10 +236,6 @@ data class AudioRecorderSettings(
|
|||||||
return copy(maxDuration = duration)
|
return copy(maxDuration = duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setForceExactMaxDuration(forceExactMaxDuration: Boolean): AudioRecorderSettings {
|
|
||||||
return copy(forceExactMaxDuration = forceExactMaxDuration)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShowAllMicrophones(showAllMicrophones: Boolean): AudioRecorderSettings {
|
fun setShowAllMicrophones(showAllMicrophones: Boolean): AudioRecorderSettings {
|
||||||
return copy(showAllMicrophones = showAllMicrophones)
|
return copy(showAllMicrophones = showAllMicrophones)
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,11 @@ data class AudioRecorderExporter(
|
|||||||
val recording: RecordingInformation,
|
val recording: RecordingInformation,
|
||||||
) {
|
) {
|
||||||
suspend fun concatenateFiles(
|
suspend fun concatenateFiles(
|
||||||
context: Context,
|
|
||||||
batchesFolder: BatchesFolder,
|
batchesFolder: BatchesFolder,
|
||||||
outputFilePath: String,
|
outputFilePath: String,
|
||||||
forceConcatenation: Boolean = false,
|
forceConcatenation: Boolean = false,
|
||||||
) {
|
) {
|
||||||
val filePaths = batchesFolder.getBatchesForFFmpeg().joinToString("|")
|
val filePaths = batchesFolder.getBatchesForFFmpeg()
|
||||||
|
|
||||||
if (batchesFolder.checkIfOutputAlreadyExists(
|
if (batchesFolder.checkIfOutputAlreadyExists(
|
||||||
recording.recordingStart,
|
recording.recordingStart,
|
||||||
@ -32,12 +31,13 @@ data class AudioRecorderExporter(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val filePathsConcatenated = filePaths.joinToString("|")
|
||||||
val command =
|
val command =
|
||||||
"-protocol_whitelist saf,concat,content,file,subfile" +
|
"-protocol_whitelist saf,concat,content,file,subfile" +
|
||||||
" -i 'concat:${filePaths}' -y" +
|
" -i 'concat:$filePathsConcatenated' -y" +
|
||||||
" -acodec copy" +
|
" -acodec copy" +
|
||||||
" -metadata date='${recording.recordingStart.format(DateTimeFormatter.ISO_DATE_TIME)}'" +
|
" -metadata date='${recording.recordingStart.format(DateTimeFormatter.ISO_DATE_TIME)}'" +
|
||||||
" -metadata batch_count='${filePaths.length}'" +
|
" -metadata batch_count='${filePaths.size}'" +
|
||||||
" -metadata batch_duration='${recording.intervalDuration}'" +
|
" -metadata batch_duration='${recording.intervalDuration}'" +
|
||||||
" -metadata max_duration='${recording.maxDuration}'" +
|
" -metadata max_duration='${recording.maxDuration}'" +
|
||||||
" $outputFilePath"
|
" $outputFilePath"
|
||||||
@ -57,9 +57,6 @@ data class AudioRecorderExporter(
|
|||||||
|
|
||||||
throw Exception("Failed to concatenate audios")
|
throw Exception("Failed to concatenate audios")
|
||||||
}
|
}
|
||||||
|
|
||||||
val minRequiredForPossibleInExactMaxDuration =
|
|
||||||
recording.maxDuration / recording.intervalDuration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -40,7 +40,6 @@ abstract class IntervalRecorderService : ExtraRecorderInformationService() {
|
|||||||
maxDuration = settings.maxDuration,
|
maxDuration = settings.maxDuration,
|
||||||
fileExtension = settings.fileExtension,
|
fileExtension = settings.fileExtension,
|
||||||
intervalDuration = settings.intervalDuration,
|
intervalDuration = settings.intervalDuration,
|
||||||
forceExactMaxDuration = settings.forceExactMaxDuration,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Make overrideable
|
// Make overrideable
|
||||||
@ -106,7 +105,6 @@ abstract class IntervalRecorderService : ExtraRecorderInformationService() {
|
|||||||
data class Settings(
|
data class Settings(
|
||||||
val maxDuration: Long,
|
val maxDuration: Long,
|
||||||
val intervalDuration: Long,
|
val intervalDuration: Long,
|
||||||
val forceExactMaxDuration: Boolean,
|
|
||||||
val bitRate: Int,
|
val bitRate: Int,
|
||||||
val samplingRate: Int,
|
val samplingRate: Int,
|
||||||
val outputFormat: Int,
|
val outputFormat: Int,
|
||||||
@ -135,7 +133,6 @@ abstract class IntervalRecorderService : ExtraRecorderInformationService() {
|
|||||||
outputFormat = audioRecorderSettings.getOutputFormat(),
|
outputFormat = audioRecorderSettings.getOutputFormat(),
|
||||||
encoder = audioRecorderSettings.getEncoder(),
|
encoder = audioRecorderSettings.getEncoder(),
|
||||||
maxDuration = audioRecorderSettings.maxDuration,
|
maxDuration = audioRecorderSettings.maxDuration,
|
||||||
forceExactMaxDuration = audioRecorderSettings.forceExactMaxDuration,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
package app.myzel394.alibi.ui.components.SettingsScreen.atoms
|
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.GraphicEq
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.Switch
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.collectAsState
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import app.myzel394.alibi.R
|
|
||||||
import app.myzel394.alibi.dataStore
|
|
||||||
import app.myzel394.alibi.db.AppSettings
|
|
||||||
import app.myzel394.alibi.ui.components.atoms.SettingsTile
|
|
||||||
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ForceExactMaxDurationTile(
|
|
||||||
settings: AppSettings,
|
|
||||||
) {
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val dataStore = LocalContext.current.dataStore
|
|
||||||
|
|
||||||
fun updateValue(forceExactMaxDuration: Boolean) {
|
|
||||||
scope.launch {
|
|
||||||
dataStore.updateData {
|
|
||||||
it.setAudioRecorderSettings(
|
|
||||||
it.audioRecorderSettings.setForceExactMaxDuration(forceExactMaxDuration)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SettingsTile(
|
|
||||||
title = stringResource(R.string.ui_settings_option_forceExactDuration_title),
|
|
||||||
description = stringResource(R.string.ui_settings_option_forceExactDuration_description),
|
|
||||||
leading = {
|
|
||||||
Icon(
|
|
||||||
Icons.Default.GraphicEq,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
trailing = {
|
|
||||||
Switch(
|
|
||||||
checked = settings.audioRecorderSettings.forceExactMaxDuration,
|
|
||||||
onCheckedChange = ::updateValue,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
@ -136,7 +136,6 @@ fun AudioRecorderScreen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AudioRecorderExporter(recording).concatenateFiles(
|
AudioRecorderExporter(recording).concatenateFiles(
|
||||||
context,
|
|
||||||
audioRecorder.recorderService!!.batchesFolder,
|
audioRecorder.recorderService!!.batchesFolder,
|
||||||
outputFile,
|
outputFile,
|
||||||
)
|
)
|
||||||
|
@ -37,14 +37,12 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import app.myzel394.alibi.R
|
import app.myzel394.alibi.R
|
||||||
import app.myzel394.alibi.dataStore
|
import app.myzel394.alibi.dataStore
|
||||||
import app.myzel394.alibi.db.AppSettings
|
|
||||||
import app.myzel394.alibi.ui.SUPPORTS_DARK_MODE_NATIVELY
|
import app.myzel394.alibi.ui.SUPPORTS_DARK_MODE_NATIVELY
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.AboutTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.AboutTile
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.BitrateTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.BitrateTile
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.CustomNotificationTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.CustomNotificationTile
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.DeleteRecordingsImmediatelyTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.DeleteRecordingsImmediatelyTile
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.EncoderTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.EncoderTile
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.ForceExactMaxDurationTile
|
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.ImportExport
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.ImportExport
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.InAppLanguagePicker
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.InAppLanguagePicker
|
||||||
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.IntervalDurationTile
|
import app.myzel394.alibi.ui.components.SettingsScreen.atoms.IntervalDurationTile
|
||||||
@ -146,7 +144,6 @@ fun SettingsScreen(
|
|||||||
)
|
)
|
||||||
MaxDurationTile(settings = settings)
|
MaxDurationTile(settings = settings)
|
||||||
IntervalDurationTile(settings = settings)
|
IntervalDurationTile(settings = settings)
|
||||||
ForceExactMaxDurationTile(settings = settings)
|
|
||||||
InAppLanguagePicker()
|
InAppLanguagePicker()
|
||||||
DeleteRecordingsImmediatelyTile(settings = settings)
|
DeleteRecordingsImmediatelyTile(settings = settings)
|
||||||
CustomNotificationTile(navController = navController, settings = settings)
|
CustomNotificationTile(navController = navController, settings = settings)
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
<string name="ui_settings_option_maxDuration_description">Set the maximum duration of the recording</string>
|
<string name="ui_settings_option_maxDuration_description">Set the maximum duration of the recording</string>
|
||||||
<string name="ui_settings_option_intervalDuration_title">Batch duration</string>
|
<string name="ui_settings_option_intervalDuration_title">Batch duration</string>
|
||||||
<string name="ui_settings_option_intervalDuration_description">Record a single batch for this duration. Alibi records multiple batches and deletes the oldest one. When exporting the audio, all batches will be merged together</string>
|
<string name="ui_settings_option_intervalDuration_description">Record a single batch for this duration. Alibi records multiple batches and deletes the oldest one. When exporting the audio, all batches will be merged together</string>
|
||||||
<string name="ui_settings_option_forceExactDuration_title">Force exact duration</string>
|
|
||||||
<string name="ui_settings_option_forceExactDuration_description">Force to strip the output file to be the exactly specified duration. If this is disabled, the output file may be a bit longer due to batches of audio samples being encoded together.</string>
|
|
||||||
<string name="ui_settings_option_bitrate_title">Bitrate</string>
|
<string name="ui_settings_option_bitrate_title">Bitrate</string>
|
||||||
<string name="ui_settings_option_bitrate_description">A higher bitrate means better quality but also larger file size</string>
|
<string name="ui_settings_option_bitrate_description">A higher bitrate means better quality but also larger file size</string>
|
||||||
<string name="ui_settings_option_bitrate_explanation">Set the bitrate for the audio recording</string>
|
<string name="ui_settings_option_bitrate_explanation">Set the bitrate for the audio recording</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user