Xuggler中的encodeAudio()方法具有以下参数:
使用来自javax.sound.sampled的javax.sound.sampled,我可以将数据读取到byte[]数组中
byte[] tempBuffer = new byte[10000];
fromMic.read(tempBuffer,0,tempBuffer.length);但问题是samples参数需要short[]
发布于 2012-12-25 19:00:30
幸运的是,byte对short来说是“完全可用的”,所以:
// Grab size of the byte array, create an array of shorts of the same size
int size = byteArray.length;
short[] shortArray = new short[size];
for (int index = 0; index < size; index++)
shortArray[index] = (short) byteArray[index];然后使用shortArray。
注意:就原语类型而言,Java总是按照大端顺序对待它们,因此,比方说,字节ff转换将产生短00ff。
https://stackoverflow.com/questions/14033217
复制相似问题