V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
hanssx
V2EX  ›  Linux

mpd 编译安装完用不了

  •  
  •   hanssx · 2021-02-23 14:20:00 +08:00 · 2077 次点击
    这是一个创建于 1150 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境

    Ubuntu 18.04 ,其实用得是 Linux Mint 19.3

    背景

    apt install mpd 自带的 mpd 版本较低,故编译安装。

    步骤

    按照 https://www.musicpd.org/doc/html/user.html 中 Compiling from source¶安装 详细安装日志烦请移步: https://pastebin.com/mG60p8q8 这里有一点比较有意思,就是最后一步ninja -C output/release install,前面不加 sudo 过不去。

    问题表现

    安装完后 mpd 报错找不到配置文件,

    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [13:47:14] 
    $ sudo mpd
    exception: No configuration file found
    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [13:47:19] C:1
    $ mpd
    exception: No configuration file found
    
    

    需要 touch 创建 /etc/mpd.conf,然后指定配置文件运行,是不是前面步骤没做好?(问题一

    明明没有运行 mpd,但是还提示 Address already in use,这是啥原因?(问题二

    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:13:23] 
    $ netstat -antlp | grep mpd
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:13:28] C:1
    $ netstat -antlp | grep 6600
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:13:52] C:1
    $ mpd /etc/mpd.conf         
    exception: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
    output: No 'audio_output' defined in config file
    output: Successfully detected a sndio audio device
    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:13:58] 
    $ netstat -antlp | grep 6600
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    tcp6       0      0 :::6600                 :::*                    LISTEN      32660/mpd           
    
    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:14:19] 
    $ ps -ef | grep mpd         
    mint64   32660  3068  0 14:13 ?        00:00:00 mpd /etc/mpd.conf
    mint64   32703  3668  0 14:14 pts/0    00:00:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mpd
    

    服务都没装上的吗,看之前提示是装到 /usr/local/lib/systemd/system 了,这个怎么运行呐。(问题三

    # mint64 @ mint64-VirtualBox in ~/mpd-0.22.6 [14:18:13] C:4
    $ systemctl status mpd.service
    Unit mpd.service could not be found.
    
    

    闲言碎语

    为了用 Linux,我最近感觉又有了年轻时的激情,但是总是遇到问题,啥时候才能配置好 i3wm 。

    第 1 条附言  ·  2021-02-23 14:52:07 +08:00
    解决了服务的问题,重新加载一下,systemctl daemon-reload,就能找到`/usr/local/lib/`下的 systemd 了。
    参考链接:
    https://github.com/coreos/rpm-ostree/issues/1936
    http://alexander.holbreich.org/systemd-services/
    第 2 条附言  ·  2021-02-23 15:01:11 +08:00

    用apt install mpd得到一个配置文件,然后再apt remove mpd,配置文件留下来,然后改systemd中加上配置文件路径,最后成功启动,感觉过于麻烦了。

    $ ps -ef | grep mpd      
    mpd       9624     1  0 14:58 ?        00:00:00 /usr/local/bin/mpd --no-daemon /etc/mpd.conf
    
    第 3 条附言  ·  2021-02-24 14:25:32 +08:00

    最后编译安装最新版的mpd、mpc之后,编译的最新版信息如下

    $ mpc version
    mpd version: 0.22.4
    
    $ mpd -V    
    Music Player Daemon 0.22.6 (0.22.6)
    
    

    依然报错如下

    $ tail -f /var/log/mpd/mpd.log
    [src/libmpg123/parse.c:1185] error: Giving up searching valid MPEG header after 65536 bytes of junk.
    Feb 24 11:48 : mpg123: mpg123_getformat() failed: Message: I am done with this track.
    Feb 24 11:48 : ffmpeg/opus: Could not update timestamps for skipped samples.
    Feb 24 11:49 : player: played "Victory.mp3"
    Feb 24 11:49 : exception: Not playing
    Feb 24 11:49 : player: played "Aloha Heja He.mp3"
    Feb 24 11:49 : mad: input does not appear to be a mp3 bit stream
    [src/libmpg123/parse.c:1185] error: Giving up searching valid MPEG header after 65536 bytes of junk.
    Feb 24 11:49 : mpg123: mpg123_getformat() failed: Message: I am done with this track.
    Feb 24 11:49 : ffmpeg/opus: Could not update timestamps for skipped samples.
    
    

    错误之一:[src/libmpg123/parse.c:1185] error: Giving up searching valid MPEG header after 65536 bytes of junk.

    通过gg搜索到https://community.volumio.org/t/parse-c-1078-error-giving-up-searching-valid-mpeg-header/419/3

    /etc/mpd.conf里面无此配置,

    decoder { plugin "ffmpeg" enabled "no" }
    

    也就没注释或删除这一说法了

    那么可能是ffmpeg不是最新版的原因,我此前通过ppa的方式已经将ffmpeg更新到最新版了,见2L回复

    那么到底问题在哪儿啊,要怎么解决才好,折腾得有点烦~

    16 条回复    2021-03-01 16:05:16 +08:00
    huangmingyou
        1
    huangmingyou  
       2021-02-24 10:55:29 +08:00
    为啥不用 vlc 或者 mplayer 呢; 用这个做服务吗
    hanssx
        2
    hanssx  
    OP
       2021-02-24 14:28:20 +08:00
    ffmpeg 最新版信息
    ```
    $ ffmpeg
    ffmpeg version 4.3.2-0york0~18.04 Copyright (c) 2000-2021 the FFmpeg developers
    built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
    configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
    libavutil 56. 51.100 / 56. 51.100
    libavcodec 58. 91.100 / 58. 91.100
    libavformat 58. 45.100 / 58. 45.100
    libavdevice 58. 10.100 / 58. 10.100
    libavfilter 7. 85.100 / 7. 85.100
    libavresample 4. 0. 0 / 4. 0. 0
    libswscale 5. 7.100 / 5. 7.100
    libswresample 3. 7.100 / 3. 7.100
    libpostproc 55. 7.100 / 55. 7.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

    ```

    ffmpeg 应该没问题,我用其他软件 vlc 是可以正常播放歌曲的,alsa 应该也没问题,现在问题就是 mpd+mpc 方式播放歌曲,有些歌曲播放不了,会被 skip 跳过,然后切换歌曲的时候还有“喇叭声”(就是很烦的瞬间声音很大的噪音)。



    @huangmingyou 大佬好,最近打算重新学习打造 i3wm,主要是把 mpd 放到 polybar 上面,然后它还是个 terminal music player,看着也够轻量,但一直没配置好,折腾好久了。
    huangmingyou
        3
    huangmingyou  
       2021-02-24 14:51:23 +08:00
    播放不了的歌曲可能是解码器不全
    hanssx
        4
    hanssx  
    OP
       2021-02-24 14:54:38 +08:00
    decoder 默认都是 enable 的,参考 https://www.musicpd.org/doc/html/user.html#configuring-decoder-plugins
    下面配置中 enabled yes 或 no,重启 mpd 服务之后依然还是报错。
    ```
    decoder {
    plugin "ffmpeg"
    enabled "yes"
    }
    ```
    hanssx
        5
    hanssx  
    OP
       2021-02-24 15:01:48 +08:00
    @huangmingyou 感谢大佬提醒,好像确实是解码模块有问题,参考
    https://www.musicpd.org/doc/html/plugins.html#decoder-plugins

    > mad¶
    Decodes MP3 files using libmad.

    mpg123¶
    Decodes MP3 files using libmpg123. Currently, this decoder does not support streams (e.g. archived files, remote files over HTTP, …), only regular local files.

    看报错内容好多都有问题,这 ubuntu 18.04 跟不上时代了吗。
    huangmingyou
        6
    huangmingyou  
       2021-02-24 16:28:27 +08:00
    mpg123 应该很老的项目了,还是 mplayer,vlc 靠谱
    huangmingyou
        7
    huangmingyou  
       2021-02-24 16:30:23 +08:00
    mpd 应该也是很老的项目了,之前还有一个网络声音服务器。
    你看看有没有比 mpd 更新的项目。
    hanssx
        8
    hanssx  
    OP
       2021-02-24 16:35:54 +08:00
    ```
    Feb 24 16:31 : mad: input does not appear to be a mp3 bit stream
    [src/libmpg123/parse.c:1185] error: Giving up searching valid MPEG header after 65536 bytes of junk.
    Feb 24 16:31 : mpg123: mpg123_getformat() failed: Message: I am done with this track.
    Feb 24 16:31 : ffmpeg/opus: Could not update timestamps for skipped samples.
    ```

    拿第一个报错的解码模块 mad 来说,已经是最新版本了呀

    ```
    sudo apt install libmad0-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    libmad0-dev is already the newest version (0.15.1b-9ubuntu18.04.1).
    ```

    这在 mpd 的官方文档中安装依赖部分好像都已经安装了。。。
    ```
    libmad0-dev libmpg123-dev libid3tag0-dev \
    libflac-dev libvorbis-dev libopus-dev
    ```
    hanssx
        9
    hanssx  
    OP
       2021-02-24 16:37:55 +08:00
    @huangmingyou mpd 在 2021 年还有更新哦,不算很老吧,大佬你平常用 fvwm 还用鼠标吗,你比如 jetbrains 和办公 ppt 、word 那一套东西,还是得用鼠标吧。
    huangmingyou
        10
    huangmingyou  
       2021-02-24 16:53:42 +08:00
    fvwm 肯定的用鼠标。 偶尔会用 keynav 这个鼠标二分模拟软件定位一个窗口焦点。
    hanssx
        11
    hanssx  
    OP
       2021-02-24 17:01:08 +08:00
    @huangmingyou 好奇看了一下你以往的发帖,发现你之前还用过 mac 。
    huangmingyou
        12
    huangmingyou  
       2021-02-24 17:20:31 +08:00   ❤️ 1
    @hanssx 尝试了几个月,还是没 linux 用着顺手,放弃了。
    hanssx
        13
    hanssx  
    OP
       2021-02-24 18:46:30 +08:00
    用了 linux mint 20 ( ubuntu 20 ),直接 apt install mpd mpc 的,也是报同样的错误。嗐~
    huangmingyou
        14
    huangmingyou  
       2021-02-24 21:43:34 +08:00
    可以找 /usr/share/doc/mpd 目录看看有没有 example
    hanssx
        15
    hanssx  
    OP
       2021-02-26 11:24:31 +08:00
    找了没有相关 example,配置文件里面好像没啥可以改动的,不知道如何修改 decoder,去官方 Issue 提问了也没人回- -
    https://github.com/MusicPlayerDaemon/MPD/issues/1107
    hanssx
        16
    hanssx  
    OP
       2021-03-01 16:05:16 +08:00
    问题已解决,禁用 mad 和 mpg123 插件即可,现在所有 mp3 都可以播放了。
    decoder {
    plugin "mad"
    enalbed "no"
    }
    decoder {
    plugin "mpg123"
    enalbed "no"
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5500 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 06:07 · PVG 14:07 · LAX 23:07 · JFK 02:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.