mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
current stand
This commit is contained in:
parent
e237a5c99e
commit
e94bfded6c
@ -55,8 +55,9 @@ data class AudioRecorderExporter(
|
|||||||
suspend fun concatenateFiles(
|
suspend fun concatenateFiles(
|
||||||
context: Context,
|
context: Context,
|
||||||
uri: Uri,
|
uri: Uri,
|
||||||
|
folder: DocumentFile,
|
||||||
forceConcatenation: Boolean = false,
|
forceConcatenation: Boolean = false,
|
||||||
): File {
|
) {
|
||||||
val filePaths = getFilePaths(context)
|
val filePaths = getFilePaths(context)
|
||||||
val paths = filePaths.joinToString("|") {
|
val paths = filePaths.joinToString("|") {
|
||||||
it.path
|
it.path
|
||||||
@ -70,11 +71,10 @@ data class AudioRecorderExporter(
|
|||||||
.toString()
|
.toString()
|
||||||
.replace(":", "-")
|
.replace(":", "-")
|
||||||
.replace(".", "_")
|
.replace(".", "_")
|
||||||
val outputFile = File("${recording.folderPath}/$fileName.${recording.fileExtension}")
|
val outputFile = FFmpegKitConfig.getSafParameterForWrite(
|
||||||
|
context,
|
||||||
if (outputFile.exists() && !forceConcatenation) {
|
(folder.uri.path + "/$fileName.aac").toUri()
|
||||||
return outputFile
|
)
|
||||||
}
|
|
||||||
|
|
||||||
val command = "-protocol_whitelist saf,concat,content,file,subfile " +
|
val command = "-protocol_whitelist saf,concat,content,file,subfile " +
|
||||||
"-i 'concat:${filePath}' -y" +
|
"-i 'concat:${filePath}' -y" +
|
||||||
@ -108,11 +108,7 @@ data class AudioRecorderExporter(
|
|||||||
|
|
||||||
val minRequiredForPossibleInExactMaxDuration =
|
val minRequiredForPossibleInExactMaxDuration =
|
||||||
recording.maxDuration / recording.intervalDuration
|
recording.maxDuration / recording.intervalDuration
|
||||||
if (recording.forceExactMaxDuration && filePaths.size > minRequiredForPossibleInExactMaxDuration) {
|
|
||||||
stripConcatenatedFileToExactDuration(outputFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -57,6 +57,14 @@ class AudioRecorderService : IntervalRecorderService() {
|
|||||||
} else {
|
} else {
|
||||||
MediaRecorder()
|
MediaRecorder()
|
||||||
}.apply {
|
}.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
|
// Setting file path
|
||||||
if (customOutputFolder == null) {
|
if (customOutputFolder == null) {
|
||||||
val newFilePath = "${defaultOutputFolder}/$counter.${settings!!.fileExtension}"
|
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}")
|
println("outputformat eta: ${settings!!.outputFormat}")
|
||||||
setOutputFormat(settings!!.outputFormat)
|
setOutputFormat(settings!!.outputFormat)
|
||||||
|
|
||||||
|
@ -96,14 +96,6 @@ fun AudioRecorderScreen(
|
|||||||
delay(100)
|
delay(100)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (settings.audioRecorderSettings.saveFolder != null) {
|
|
||||||
AudioRecorderExporter.linkBatches(
|
|
||||||
context,
|
|
||||||
settings.audioRecorderSettings.saveFolder.toUri(),
|
|
||||||
AudioRecorderExporter.getFolder(context),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val file = AudioRecorderExporter(
|
val file = AudioRecorderExporter(
|
||||||
audioRecorder.recorderService?.getRecordingInformation()
|
audioRecorder.recorderService?.getRecordingInformation()
|
||||||
?: settings.lastRecording
|
?: settings.lastRecording
|
||||||
@ -114,9 +106,13 @@ fun AudioRecorderScreen(
|
|||||||
context,
|
context,
|
||||||
settings.audioRecorderSettings.saveFolder!!.toUri(),
|
settings.audioRecorderSettings.saveFolder!!.toUri(),
|
||||||
)!!.findFile("1.aac")!!.uri,
|
)!!.findFile("1.aac")!!.uri,
|
||||||
|
DocumentFile.fromTreeUri(
|
||||||
|
context,
|
||||||
|
settings.audioRecorderSettings.saveFolder!!.toUri(),
|
||||||
|
)!!
|
||||||
)
|
)
|
||||||
|
|
||||||
saveFile(file, file.name)
|
//saveFile(file, file.name)
|
||||||
} catch (error: Exception) {
|
} catch (error: Exception) {
|
||||||
Log.getStackTraceString(error)
|
Log.getStackTraceString(error)
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user