current stand

This commit is contained in:
Myzel394 2023-11-17 17:40:33 +01:00
parent e237a5c99e
commit e94bfded6c
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
3 changed files with 19 additions and 26 deletions

View File

@ -55,8 +55,9 @@ data class AudioRecorderExporter(
suspend fun concatenateFiles(
context: Context,
uri: Uri,
folder: DocumentFile,
forceConcatenation: Boolean = false,
): File {
) {
val filePaths = getFilePaths(context)
val paths = filePaths.joinToString("|") {
it.path
@ -70,11 +71,10 @@ data class AudioRecorderExporter(
.toString()
.replace(":", "-")
.replace(".", "_")
val outputFile = File("${recording.folderPath}/$fileName.${recording.fileExtension}")
if (outputFile.exists() && !forceConcatenation) {
return outputFile
}
val outputFile = FFmpegKitConfig.getSafParameterForWrite(
context,
(folder.uri.path + "/$fileName.aac").toUri()
)
val command = "-protocol_whitelist saf,concat,content,file,subfile " +
"-i 'concat:${filePath}' -y" +
@ -108,11 +108,7 @@ data class AudioRecorderExporter(
val minRequiredForPossibleInExactMaxDuration =
recording.maxDuration / recording.intervalDuration
if (recording.forceExactMaxDuration && filePaths.size > minRequiredForPossibleInExactMaxDuration) {
stripConcatenatedFileToExactDuration(outputFile)
}
return outputFile
}
companion object {

View File

@ -57,6 +57,14 @@ class AudioRecorderService : IntervalRecorderService() {
} else {
MediaRecorder()
}.apply {
// Audio Source is kinda strange, here are my experimental findings using a Pixel 7 Pro
// and Redmi Buds 3 Pro:
// - MIC: Uses the bottom microphone of the phone (17)
// - CAMCORDER: Uses the top microphone of the phone (2)
// - VOICE_COMMUNICATION: Uses the bottom microphone of the phone (17)
// - DEFAULT: Uses the bottom microphone of the phone (17)
setAudioSource(MediaRecorder.AudioSource.MIC)
// Setting file path
if (customOutputFolder == null) {
val newFilePath = "${defaultOutputFolder}/$counter.${settings!!.fileExtension}"
@ -73,13 +81,6 @@ class AudioRecorderService : IntervalRecorderService() {
}
}
// Audio Source is kinda strange, here are my experimental findings using a Pixel 7 Pro
// and Redmi Buds 3 Pro:
// - MIC: Uses the bottom microphone of the phone (17)
// - CAMCORDER: Uses the top microphone of the phone (2)
// - VOICE_COMMUNICATION: Uses the bottom microphone of the phone (17)
// - DEFAULT: Uses the bottom microphone of the phone (17)
setAudioSource(MediaRecorder.AudioSource.MIC)
println("outputformat eta: ${settings!!.outputFormat}")
setOutputFormat(settings!!.outputFormat)

View File

@ -96,14 +96,6 @@ fun AudioRecorderScreen(
delay(100)
try {
if (settings.audioRecorderSettings.saveFolder != null) {
AudioRecorderExporter.linkBatches(
context,
settings.audioRecorderSettings.saveFolder.toUri(),
AudioRecorderExporter.getFolder(context),
)
}
val file = AudioRecorderExporter(
audioRecorder.recorderService?.getRecordingInformation()
?: settings.lastRecording
@ -114,9 +106,13 @@ fun AudioRecorderScreen(
context,
settings.audioRecorderSettings.saveFolder!!.toUri(),
)!!.findFile("1.aac")!!.uri,
DocumentFile.fromTreeUri(
context,
settings.audioRecorderSettings.saveFolder!!.toUri(),
)!!
)
saveFile(file, file.name)
//saveFile(file, file.name)
} catch (error: Exception) {
Log.getStackTraceString(error)
} finally {