tags:

views:

39

answers:

2

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.

A: 

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).

Aaron Digulla
There is an adjustment "tool" that is used in the code on the input data to do these conversions. The reason that I don't think its sample rate related is because when using 44100 stereo to 44100 stereo, the issue still occurs.
Mondain
What does `mediainfo` say about the output file? Maybe there is a bug.
Aaron Digulla
I'm not familiar with "mediainfo" but I will take a look at it. I can say that the file seems fine and I have the same result with other files. The problem is most definitely in the queue code, because skipping the queue provides working output at the correct speed.
Mondain
A: 

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.

Mondain
"2" in this case because I'm using a stereo source
Mondain