Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only mono audio (just left channel) #2905

Closed
gentoolinux opened this issue Mar 5, 2016 · 8 comments
Closed

Only mono audio (just left channel) #2905

gentoolinux opened this issue Mar 5, 2016 · 8 comments

Comments

@gentoolinux
Copy link

If I play a file using mpv, I only get mono audio output (just the left channel is played):

$ mpv file.mp4
Playing: file.mp4
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=und (*) (aac)
AO: [alsa] 48000Hz mono 1ch float

With other programs like mplayer I have stereo audio:

$ mplayer file.mp4
MPlayer SVN-r37373 (Gentoo)-4.8.5 (C) 2000-2015 MPlayer Team

Playing file.mp4.
libavformat version 56.40.101 (external)
Mismatching header version 56.25.101
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8275c7b8c0]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO:  [H264]  1280x720  24bpp  30.000 fps  2216.3 kbps (270.5 kbyte/s)
Clip info:
 major_brand: isom
 minor_version: 1
 compatible_brands: isomavc1mp42
 creation_time: 2015-11-05 16:13:50
Load subtitles in ./
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 56.60.100 (external)
Mismatching header version 56.26.100
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, floatle, 127.4 kbit/4.15% (ratio: 15928->384000)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [alsa] 48000Hz 2ch floatle (4 bytes per sample)
Starting playback...

Here are the relevant parts of the mpv verbose output:

$ mpv -v --no-video file.mp4 
[cplayer] Command line options: '-v' '--no-video' 'file.mp4'
[cplayer] mpv 0.16.0 (C) 2000-2016 mpv/MPlayer/mplayer2 projects
[cplayer]  built on UNKNOWN
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       54.31.100
[cplayer]    libavcodec      56.60.100
[cplayer]    libavformat     56.40.101
[cplayer]    libswscale      3.1.101
[cplayer]    libavfilter     5.40.101
[cplayer]    libswresample   1.2.101
[cplayer] ffmpeg version: 2.8.5
[cplayer]
[cplayer] Configuration: /var/tmp/portage/media-video/mpv-0.16.0/work/mpv-0.16.0/waf --prefix=/usr --libdir=/usr/lib64 --confdir=/etc/mpv --docdir=/usr/share/doc/mpv-0.16.0 --disable-gpl3 --enable-libmpv-shared --disable-libmpv-static --disable-static-build --disable-optimize --disable-debug-build --disable-html-build --disable-pdf-build --disable-vf-dlopen-filters --disable-zsh-comp --disable-test --enable-iconv --disable-libsmbclient --enable-lua --enable-libass --enable-libass-osd --enable-encoding --disable-libbluray --enable-dvdread --enable-dvdnav --disable-cdda --enable-enca --disable-libguess --disable-uchardet --disable-rubberband --disable-lcms2 --disable-vapoursynth --disable-vapoursynth-lazy --disable-libarchive --enable-libavdevice --disable-sdl2 --disable-sdl1 --disable-oss-audio --disable-rsound --disable-pulse --disable-jack --disable-openal --disable-opensles --enable-alsa --disable-coreaudio --disable-cocoa --disable-drm --disable-gbm --disable-wayland --enable-x11 --enable-xss --enable-xext --enable-xv --disable-xinerama --enable-xrandr --enable-gl-x11 --enable-egl-x11 --disable-egl-drm --disable-gl-wayland --disable-vdpau --disable-vdpau-gl-x11 --enable-vaapi --enable-vaapi-x11 --disable-vaapi-wayland --disable-vaapi-drm --disable-caca --enable-jpeg --disable-android --disable-rpi --enable-desktop-gl --enable-vaapi-hwaccel --enable-tv --enable-tv-v4l2 --enable-libv4l2 --enable-audio-input --enable-dvbin --enable-vaapi-glx --enable-vaapi-x-egl --disable-build-date configure
[cplayer] List of enabled features: alsa any-gl asm atomics audio-input av-pix-fmt-mmal av-version-info avcodec-chroma-pos-api avframe-metadata avframe-skip-samples c11-tls cplayer desktop-gl dlopen dvbin dvdnav dvdread egl-helpers egl-x11 enca encoding fchmod gbm.h gl gl-x11 glibc-thread-name glob iconv jpeg libass libass-osd libav libavdevice libavfilter libdl libm libmpv-shared librt libswresample libv4l2 linux-fstatfs lua nanosleep plain-gl posix posix-or-mingw posix-spawn pthreads resampler shm sse4-intrinsics stdatomic subprocess termios tv tv-v4l2 vaapi vaapi-egl vaapi-glx vaapi-hwaccel vaapi-x-egl vaapi-x11 videodev vt.h x11 xext xrandr xss xv zlib

[...]

[cplayer] Playing: file.mp4
[cplayer] Running hook: ytdl_hook/on_load
[cplayer] Run command: hook-ack, flags=0, args=[on_load]
[ifo] Opening file.mp4
[ifo/dvdnav] Opening file.mp4
[file] Opening file.mp4
[file] Stream opened successfully.
[demux] Trying demuxers for level=normal.
[lavf] Found 'mov,mp4,m4a,3gp,3g2,mj2' at score=100 size=2048.
[lavf] avformat_find_stream_info() finished after 196608 bytes.
[demux] Detected file format: mov,mp4,m4a,3gp,3g2,mj2 (libavformat)
[find_files] Loading external files in .
[global] config path: 'sub/' -/-> '/home/asdf/.mpv/sub/'
[global] config path: 'sub/' -/-> '/etc/mpv/sub/'
[global] config path: 'audio/' -/-> '/home/asdf/.mpv/audio/'
[global] config path: 'audio/' -/-> '/etc/mpv/audio/'
[cplayer]      Video --vid=1 (*) (h264)
[cplayer]  (+) Audio --aid=1 --alang=und (*) (aac)
[ad] Codec list:
[ad]     lavc:aac - AAC (Advanced Audio Coding)
[ad]     lavc:aac_fixed (aac) - AAC (Advanced Audio Coding)
[ad] Opening audio decoder lavc:aac
[ad] Requesting 1 threads for decoding.
[ad] Selected audio codec: AAC (Advanced Audio Coding) [lavc:aac]
[cplayer] Starting playback...
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch floatp
[af]   [out] 48000Hz stereo 2ch floatp
[af]   [ao] 48000Hz stereo 2ch floatp
[ao] Trying audio driver 'alsa'
[ao/alsa] requested format: 48000 Hz, stereo channels, floatp
[ao/alsa] using ALSA version: 1.0.29
[ao/alsa] opening device 'default'
[ao/alsa] trying format float
[ao/alsa] skipping unknown ALSA channel map: FL FR FL FR FL FR FL FR
[ao/alsa] Channel layouts:
[ao/alsa] channel map reported by ALSA: FL
[ao/alsa] which we understand as: mono
[ao/alsa] using the ALSA channel map.
[ao/alsa] hw pausing supported: yes
[ao/alsa] buffersize: 8192 samples
[ao/alsa] period size: 512 samples
[ao/alsa] device buffer: 8192 samples.
[ao/alsa] using soft-buffer of 9600 samples.
[cplayer] AO: [alsa] 48000Hz mono 1ch float
[cplayer] AO: Description: ALSA audio output
[af] Adding filter lavrresample
[lavrresample] Remix: stereo -> mono
[lavrresample] Remix: stereo -> mono
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch floatp
[af]   [lavrresample] 48000Hz mono 1ch float
[af]   [out] 48000Hz mono 1ch float
[af]   [ao] 48000Hz mono 1ch float
[cplayer] playback restart complete

This is my asound.conf I use for simultaneous audio output via analog audio jack, HDMI, S/PDIF and DisplayPort:

pcm.multi {
    type multi
    slaves.a.pcm "hw:1,0"       # analog
    slaves.a.channels 2
    slaves.b.pcm "hw:1,1"       # S/PDIF
    slaves.b.channels 2
    slaves.c.pcm "hw:0,3"       # DisplayPort
    slaves.c.channels 2
    slaves.d.pcm "hw:0,7"       # HDMI
    slaves.d.channels 2

    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
    bindings.4.slave c
    bindings.4.channel 0
    bindings.5.slave c
    bindings.5.channel 1
    bindings.6.slave d
    bindings.6.channel 0
    bindings.7.slave d
    bindings.7.channel 1
}

pcm.!default {
    type plug
    slave {
        pcm multi
        channels 8
    }

    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1
    ttable.0.4 1
    ttable.1.5 1
    ttable.0.6 1
    ttable.1.7 1
}

ctl.multi {
    type hw;
    card 0;
}
@ghost
Copy link

ghost commented Mar 5, 2016

[ao/alsa] skipping unknown ALSA channel map: FL FR FL FR FL FR FL FR

Looks like a pretty broken ALSA driver. Or since your config might be doing that, a pretty broken ALSA config.

@gentoolinux
Copy link
Author

[ao/alsa] skipping unknown ALSA channel map: FL FR FL FR FL FR FL FR

Looks like a pretty broken ALSA driver. Or since your config might be doing that, a pretty broken ALSA config.

Thanks for your quick reply. The strange thing is that every other program except mpv works fine.
Do you have any advice what I can do to solve this? Should I report this to the ALSA team? If it's the config, what would be the correct way to achieve simultaneous audio output with plain ALSA?

@ghost
Copy link

ghost commented Mar 5, 2016

Most programs probably don't try to use the channel map, and only output stereo.

@ghost
Copy link

ghost commented Mar 5, 2016

PS: I'm not sure what ALSA is expecting there, but mpv definitely won't duplicate the left/right channel for every following channel pair, like the channel map seems to indicate it.

@ghost ghost added the meta:info-needed label Apr 3, 2016
@mia-0
Copy link
Member

mia-0 commented Nov 5, 2016

This might be solved with the new default for --audio-channels, but if it’s not, explicitly specify audio-channels=2 in your config, maybe even alsa-ignore-chmap. Should make it work.

@gentoolinux
Copy link
Author

I have upgraded to mpv-0.21.0. By default I still have only mono audio. Adding the parameter --audio-channels=2 or specifying audio-channels=2 in the config file does not change anything. But adding alsa-ignore-chmap to the config file did work. Thank you!

If someone is using an older mpv version and has the same problem: Use the parameter --ao=alsa:ignore-chmap.

ghost pushed a commit that referenced this issue Nov 8, 2016
If the input is already mono or stereo, or if channel map selection
results in mono or stereo, then disable further use of the champ ALSA
API (or rather, stop trusting its results). Then we behave like a simple
application that only wants to output mono or stereo.

See #3045 and #2905. I couldn't actually test these cases, but this
commit is supposed to fix them.
@ghost
Copy link

ghost commented Nov 8, 2016

Please retest with git master.

@gentoolinux
Copy link
Author

Thank you, problem is fixed. Now I have stereo sound by default (no need to add a parameter or add something to the config file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants