开发者

Audio playing too fast

开发者 https://www.devze.com 2023-01-13 13:15 出处:网络
If any of my fellow Xuggler users can tell me what I\'m doing wrong, that would be awesome! I am doing the following:

If any of my fellow Xuggler users can tell me what I'm doing wrong, that would be awesome! I am doing the following:

  1. Reading from ogv (ogg video)
  2. Queueing the开发者_如何学编程 audio and video
  3. Writing back to ogv

sounds simple right? The problem I am experiencing in my QueueMixer class is that the output file plays the audio 2x too fast, and no matter what I check or change with regards to pts it doesnt improve.

The eclipse project and all files being used are at this link: http://dl.dropbox.com/u/7316897/paul-xuggled.zip

To run a test, compile and execute the StreamManager class; a test ogv file is included. Before anyone asks, yes I have to queue the data as it will be mixed with other data in a future version.


Audio has a sample rate. Make sure that you copy the sample rate from the input to the output, otherwise the system might use a default (like 44KHz while the original data was sampled at 22KHz which would create such an effect).


The fix is to multiply the sample count by two when extracting them from the ShortBuffer.

samples = new short[(int) audioSamples.getNumSamples() * 2];
audioSamples.getByteBuffer().asShortBuffer().get(samples);
Having half the samples causes the audio to play twice as fast.

0

精彩评论

暂无评论...
验证码 换一张
取 消