Linux How can I chage the audio output device from the command line.
#1
I have a bit of media that doesn't play correctly on the XBMC player and on those occasions I just SSH in and watch them by starting mplayer from the command line with any needed options to watch them correctly. To do that I have to go into the settings and change the audio output device in order to unblock it for use by mplayer.

I would like to know if it is possible from the command line so I can script it.

Something like

#!/bin/bash

(command to change output)
export DISPLAY=:0
mplayer -fs -ao etc...
(cammand to change output back)
Reply
#2
I think you want to modify ~/.xbmc/userdata/guisettings.xml

I have my audio device and passthrough device set to "hdmi (ALSA)" in XBMC and the relevant section looks like this:
Code:
<audiooutput>
        <ac3passthrough>true</ac3passthrough>
        <audiodevice>alsa:plug:hdmi</audiodevice>
        <channellayout>0</channellayout>
        <customdevice>hdmi</customdevice>
        <custompassthrough></custompassthrough>
        <dontnormalizelevels>true</dontnormalizelevels>
        <dtspassthrough>true</dtspassthrough>
        <mode>2</mode>
        <passthroughaac>false</passthroughaac>
        <passthroughdevice>alsa:hdmi</passthroughdevice>
        <passthroughmp1>false</passthroughmp1>
        <passthroughmp2>false</passthroughmp2>
        <passthroughmp3>false</passthroughmp3>
</audiooutput>

Note the use of plug to denote that the PC is doing the decoding. Ignore the residual settings for customdevice. To change this file on the command line, you might do something like this:

Code:
perl -p -i -e 's#<audiodevice>[^<]*</audiodevice>#<audiodevice>yourNewDeviceHere</audiodevice>#' /home/user/.xbmc/userdata/guisettings.xml

I have no idea if XBMC watches this file for changes. It's possible that it is only read at startup and on UI events within the audio settings window. There may be a command that you can send to ALSA or Pulse to get XBMC to release the device.
HTPC 1 - Zotac ZBOX ID80U | 4GB RAM | 64GB SSD | Openelec | Confluence
HTPC 2 - Zotac ZBOX ID41U | 4GB RAM | 60GB SSD | Openelec | Confluence
Server - unRAID Server | 3 x 2TB WD Green HDD, 1TB WD Black HDD (Cache) | Sabnzbd | CouchPotato | Sickbeard
Reply
#3
Thanks, I have tested that and it turns out that the file isn't checked except at start so I have to keep looking since the only way with that is to restart the xbmc-live service which I don't want to do since that requires password input to get root permissions. Plus it would require me to go into a ssh shell and not just pass it at the command line using ssh xbmc@htpc.local 'script video.mkv'
Reply

Logout Mark Read Team Forum Stats Members Help
How can I chage the audio output device from the command line.0