[MPlayer-users] Getting the best sound from mplayer

Vladimir Mosgalin mosgalin at VM10124.spb.edu
Wed Jul 20 12:47:31 CEST 2011


Hi Grant!

 On 2011.07.19 at 11:56:48 -0700, Grant wrote next:

> I'm trying to implement something that will work in all situations
> without me determining how many channels a video has and changing the
> command line based on that before I can play it optimally.  Can I have
> ALSA downmix so that all multichannel audio is downmixed using this
> superior method?  I could even use libsamplerate_best with ALSA.
> 
> If not, is there any way to select a higher quality resampling than
> the default in mplayer?

>From manpage:
       -srate <Hz>
              Select the output sample rate to be used (of course sound cards have limits on this).  If the  sample  frequency
              selected is different from that of the current media, the resample or lavcresample audio filter will be inserted
              into the audio filter layer to compensate for the difference.  The type of resampling can be controlled  by  the
              -af-adv option.  The default is fast resampling that may cause distortion.

lavcresample provides satisfactory resampling when it's set for high
quality mode. So just try selecting higher quality mode for audio
filters with -af-adv (check manpage).


Other than that, I can recommend you to check out pulseaudio again. It's
simplest way to get guaranteed high quality audio both for mplayer and
all other sources; you can select high quality resampling there
(note, that *very highest quality* eats too much cpu and badly affects
latency under load, too), including libsamplerate_best or ffmpeg's
lavcresample and some others, and permanently lock output to, say,
24/96 mode.

> I tried this:
> 
> mplayer -channels 6 -ao alsa:device=plughw=0.0 -format s24le title.mkv
> 
> but got the same results with missing sound.  Shouldn't ALSA downmix
> the 6 channels to 2 if I specify plughw like this?

No, plughw only does very necessary convertions to allow output to work
at all and never any extra. Like, for example, if you feed 44100 but
your audio card supports only 48k samples, it will convert 44.1->48 but
nothing else; or if you feed 16 bit stream to it but your sound card
supports only 24-bit sampled audio, it will convert s16 to s24. It can
upconvert stereo to multichannel (by simply filling other channels with
silence) for sound cards that accept only multichannel - there are such
beasts - but it will never do any extra steps, not to introduce
undesirable effects. Basically plughw is just "compatible" version of hw
that takes care of most obvious incompatibilities which make playback
impossible; as long as playback IS possible, plughw does no conversion.

You can try setting up your own alsa device, though I doubt there is alsa
filter equivalent to "pan" in mplayer. But maybe there is one.

> 
> Does mplayer resample to 16/48 regardless of the source's sample size and rate?

No, it will pass output as is. Maybe with *some* specific output drivers
it can change sample size or rate automatically, when output driver
demands some type of stream, not sure, but it's not the common case.

Like I said, probably simplest way to ensure that no application ever
changes sample rate or size (well, almost; you obviously can't control
all cases, but most important applications won't) is to use pulseaudio
with output locked to 96/24 or similar. With that, every application
always feeds unaltered stream to pulse and all conversions take place
only in pulseaudio, where you ensure that they are high quality.

Though, pulseaudio won't be doing multichannel-to-stereo conversion; you
still have to do it in mplayer.

-- 

Vladimir


More information about the MPlayer-users mailing list