mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
current stand
This commit is contained in:
parent
e237a5c99e
commit
e94bfded6c
@ -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 {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user