I need PCM in AV_SAMPLE_FMT_S16 format, but I can't do it.
In stackoverflow told AV_SAMPLE_FMT_FLTP is float planar that sign pFrame.extended_data(channel) contains a float array in range from -1.0f to 1.0f.
Next, for extract values i use DataInputStream,
val linesize = pFrame.linesize(0)
// allocate buffers
val byteArrayCh0 = ByteArray(linesize)
val byteArrayCh1 = ByteArray(linesize)
// fill buffers
pFrame.extended_data(0).get(byteArrayCh0, 0 , linesize)
pFrame.extended_data(1).get(byteArrayCh1, 0 , linesize)
// convert for read the buffers
val dis0 = DataInputStream(byteArrayCh0.inputStream())
val dis1 = DataInputStream(byteArrayCh1.inputStream())
var k = 0L
while (k<nb_samples) {
val sampleFromCh0 = dis0.readFloat()
val sampleFromCh1 = dis1.readFloat()
outputBuffer2[k * channels + 0] = (sampleFromCh0 * 32767.0f).toInt()
outputBuffer2[k * channels + 1] = (sampleFromCh1 * 32767.0f).toInt()
k++
}
But it does not work. I hear only noise. For the test, I convert some mp3 file by cli and different results by
In my decode loop i have a frame that contains data
I need PCM in AV_SAMPLE_FMT_S16 format, but I can't do it. In stackoverflow told AV_SAMPLE_FMT_FLTP is float planar that sign pFrame.extended_data(channel) contains a float array in range from -1.0f to 1.0f. Next, for extract values i use DataInputStream,
But it does not work. I hear only noise. For the test, I convert some mp3 file by cli and different results by
How I can read these float arrays?