Как установить битрейт aac файла? - PullRequest
0 голосов
/ 28 января 2019

Я пытаюсь сгенерировать aac файл на Android.Я успешно сделал это.Но у меня есть немного неприятная вещь.Когда я открываю свой файл в VLC, он обнаруживает мой файл со следующими параметрами:

  • sampleSize = 32 (но он записан с размером кадра 16 бит)
  • sampleRate = 16 (но этозаписывается с частотой 8 кГц)
  • channelCount = 2 (но записывается с 1 каналом)

Где я должен указать размер выборки?Я могу указать только частоту дискретизации.

Здесь мой код, который генерирует заголовок ADTS

val id = 0
val layer = 0
val protectionAbsent = 1
val profile = 2
val frequencyIndex = 11
val privateBit = 0
val channelConfig = 1
val originalCopy = 0
val home = 0
val copyritingIdBit = 0
val copyritingIdStart = 0
val frameLength = 775

val arr = ByteArray(7)
arr[0] = 0xff.toByte()
arr[1] = (0xf0 or ((id shl 3) and 0b1000) or ((layer shl 1) and 0b110) or (protectionAbsent and 0b1)).toByte()
arr[2] = ((((profile - 1) shl 6) and 0b11000000) or ((frequencyIndex shl 2) and 0b111100) or ((privateBit shl 1) and 0b00000010) or ((channelConfig shr 2) and 0b1)).toByte()
arr[3] = (((channelConfig shl 6) and 0b11000000) or ((originalCopy shl 5) and 0x100000) or ((home shl 4) and 0b10000) or ((copyritingIdBit shl 3) and 0b00001000) or ((copyritingIdStart shl 2) and 0b00000100) or ((frameLength shr 11) and 0b11)).toByte()
arr[4] = ((frameLength shr 3) and 0xff).toByte() 
arr[5] = (((frameLength shl 5) and 0b11100000) or 0x1f).toByte()
arr[6] = 0xfc.toByte()

Когда я изменяю частоту на 16 кГц, она определяется как 32 кГц.MacOs правильно определяет частоту.

Все проигрыватели воспроизводят записи правильно.

...