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

Giacomo Comes comes at naic.edu
Thu Oct 21 19:08:41 CEST 2004


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)

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

> 
> 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.
if m=3 and n=2 then in test.avi there is ONLY noise.

Conclusion:
with mencoder you can use
	-srate AND (-af resample XOR -af-adv force)

Giacomo




More information about the MPlayer-dev-eng mailing list