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.

Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131
  • My fellow engineers, don't be put-off by the fact that I'm using ogv (ogg video) here, you can easily change the type of file to flv, mp4, mov, etc. – Paul Gregoire Aug 31 '10 at 15:45

2 Answers2

0

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
  • 321,842
  • 108
  • 597
  • 820
  • 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. – Paul Gregoire Aug 30 '10 at 16:47
  • What does `mediainfo` say about the output file? Maybe there is a bug. – Aaron Digulla Aug 31 '10 at 07:22
  • 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. – Paul Gregoire Sep 02 '10 at 16:19
0

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.

Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131