[MPlayer-dev-eng] [PATCH] fix for -srate bug

Giacomo Comes comes at naic.edu
Thu Oct 21 22:07:38 CEST 2004


On Thu, Oct 21, 2004 at 03:32:01PM -0400, D Richard Felker III wrote:
> On Thu, Oct 21, 2004 at 01:08:41PM -0400, Giacomo Comes wrote:
> > On Thu, Oct 21, 2004 at 10:55:51AM -0400, D Richard Felker III wrote:
> > > On Thu, Oct 21, 2004 at 01:22:20PM +0200, Diego Biurrun wrote:
> > > > D Richard Felker III writes:
> > > > > On Tue, Oct 19, 2004 at 01:37:02AM +0200, Diego Biurrun wrote:
> > > > > > Giacomo Comes writes:
> > > > > > > 
> > > > > > > This should go in the documentation, or mencoder should be fixed and be able to use
> > > > > > > -af resample without -srate.
> > > > > > 
> > > > > > What is the problem, -af should work with MEncoder.
> > > > > 
> > > > > it doesn't. when the broken af was first committed it was designed for
> > > > > the output end to be overridden by the negotiated parameters between
> > > > > the codec and the ao driver. mplayer was fixed but mencoder never was.
> > > > > so even if you specify resample, mencoder will reconfigure your
> > > > > resample filter to resample to the original rate... :(
> > > > 
> > > > OK, let me try to distill this into documentation.  Currently in the
> > > > man page we have
> > > > 
> > > > resample[=srate[:sloppy][:type]]
> > > >   Changes the sample rate of the audio stream to an integer srate in Hz.
> > > >   It only supports the 16-bit little-endian format.
> > > > 
> > > > IIUC I would just have to mark this MPlayer only, right?  Like so:
> > > 
> > > no. it's not mplayer-only!! it works with either, but you must
> > > force-override the output samplerate to keep mencoder from undoing
> > > your filter chain. so, something like:
> > > 
> > > -af resample=44100:0:0 -srate 44100
> > 
> > Is this really true?
> > I'm not sure. I did this test:
> > (source.asf has 8000Hz audio)
> 
> probably mono too.. or 8bit?

mono, 16 bit

> > 1) mplayer source.asf -af resample=44100:0:0 (audio has distortion)
> > 2) mplayer source.asf -af resample=44100:0:1 (audio ok)
> > 3) mplayer source.asf -af resample=44100:0:2 (audio has noise)
> > 
> > mencoder source.asf -ovc lavc -oac lavc -srate 44100 -frames 150 -af resample=44100:0:0
> > (the output is test.avi and has mp2 audio)
> > test.avi has distortion as in 1)
> > 
> > mencoder source.asf -ovc lavc -oac lavc -srate 44100 -frames 150 -af resample=44100:0:1
> > test.avi is ok as in 2)
> > 
> > mencoder source.asf -ovc lavc -oac lavc -srate 44100 -frames 150 -af resample=44100:0:2
> > test.avi is ok as in 2) but the volume is higher
> > (this is different from what expected)
> > 
> > So, may be resample works (with -srate) for mencoder too, but at least in one case
> > it works differently (bug?).
> 
> mode 2 (float) resample is ALWAYS broken for me (produces white noise)
> so i have no idea...
> 
> > > adding -af-adv force=3 (disable) couldn't hurt either..
> > 
> > No. It does hurt. With:
> > 
> > mencoder source.asf -ovc lavc -oac lavc -srate 44100 -frames 150 -af resample=44100:0:n -af-adv force=m
> > 
> > if m=0,1,2 the -af-adv option doesn't do anything. 
> > It is the n in resample that select the resample algorithm.
> > 
> > if m=3 and n=0,1 then the audio in test.avi goes at double speed. 
> > I need to play it with -speed 0.5 in order to listen a 
> > normal speed sound.

Oh, I understand. When there are no filters mplayer plays the
1 channel audio as 2 channels. That's explain the double speed.

> > if m=3 and n=2 then in test.avi there is ONLY noise.

And this means (probably) that the (integer) samples are read as float 
and the result is NOISE.

> > 
> > Conclusion:
> > with mencoder you can use
> > 	-srate AND (-af resample XOR -af-adv force)
> 
> no, you need to explain better what you're doing. most likely more
> filters are needed (which would be autoloaded if you didn't force them
> off) and so you need to load the right filters manually. there are
> many possible conditions so i can only guess...

Yes you are right. There was a needed filter forced off that confused me.

Diego, I suggest then for the man page:

resample[=srate[:sloppy][:type]]
  Changes the sample rate of the audio stream to an integer srate in Hz.
  It only supports the 16-bit little-endian format.
  With mencoder, you need to use -srate srate too.

(or a proper way to express the same thing in english).

Giacomo


Giacomo




More information about the MPlayer-dev-eng mailing list