SkillAgentSearch skills...

AirConnect

Use AirPlay to stream to UPnP/Sonos & Chromecast devices

Install / Use

/learn @philippe44/AirConnect
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

AirConnect: Send audio to UPnP/Sonos/Chromecast players using AirPlay

Use these applications to add AirPlay capabilities to Chromecast and UPnP (like Sonos) players, to make them appear as AirPlay devices.

AirConnect can run on any machine that has access to your local network (Windows, MacOS x86 and arm64, Linux x86, x86_64, arm, aarch64, sparc, mips, powerpc, Solaris and FreeBSD). It does not need to be on your main computer. (For example, a Raspberry Pi works well). It will detect UPnP/Sonos/Chromecast players, create as many virtual AirPlay devices as needed, and act as a bridge/proxy between AirPlay clients (iPhone, iPad, iTunes, MacOS, AirFoil ...) and the real UPnP/Sonos/Chromecast players.

The audio, after being decoded from alac, can be sent in plain, or re-encoded using mp3, aac or flac. Most players will not display metadata (artist, title, album, artwork ...) except when mp3 or aac re-encoding are used and for UPnP/DLNA devices that support icy protocol. Chromecast players support this after version 1.1.x

Installing

  1. Pre-built binaries are in AirConnect-<X.Y.Z>.zip. It can be downloaded manually in a terminal by typing wget https://raw.githubusercontent.com/philippe44/AirConnect/master/AirConnect-<X.Y.Z>.zip. Unzip the file an select the binary that works for your system.

    • For Chromecast, the file is aircast-<os>-<cpu> (so aircast-macos-x86_64 for Chromecast on MacOS + Intel CPU)
    • For UPnP/Sonos, the file is airupnp-<os>-<cpu> (so airupnp-macos-arm64 for UPnP/Sonos on MacOS + arm CPU)
  2. There is a "-static" version of each application that has all static libraries built-in. Use of these is (really) not recommended unless the regular version fails. For MacOS users, you need to install openSSL and do the following steps to use the dynamic load library version:

    • install openssl: brew install openssl. This creates libraries (or at least links) into /usr/local/opt/openssl[/x.y.z]/lib where optional 'x.y.z' is a version number
    • create links to these libraries:
    ln -s /usr/local/opt/openssl[/x.y.z]/lib/libcrypto.dylib /usr/local/lib/libcrypto.dylib 
    ln -s /usr/local/opt/openssl[/x.y.z]/lib/libssl.dylib /usr/local/lib/libssl.dylib 
    
  3. For Windows, install the Microsoft VC++ redistributable found here You will also need to grab the 2 dlls files and put them in the same directory as the exe file

  4. Store the <executable> (e.g. airupnp-linux-aarch64) in any directory.

  5. On non-Windows machines, open a terminal and change directories to where the executable is stored and run chmod +x <executable> (Example: chmod +x airupnp-macos). File permissions might need to be set.

  6. Don't use firewall or set ports using options below and open them.

    • Port 5353 (UDP) is needed to listen to mDNS messages
    • Each device uses 1 port permanently (RTSP) and when playing adds 1 port for HTTP and 3 ports for RTP (use -gor <ports> parameter, default is random)
    • UPnP adds one extra port for discovery (use -b or <upnp_socket> parameter, default is 49152 and user value must be above this)
  7. @faserF has made a script for install/update ter)

  8. In Docker, you must use 'host' mode to enable audio webserver. Note that you can't have a NAT between your devices and the machine where AirConnect runs.

Running

Double click the <executable> or launch it by typing ./<executable> in the same command line window.

<strong>For Sonos & Heos players, set latency by adding -l 1000:2000 on the command line.</strong> (Example: ./airupnp-macos -l 1000:2000)

You should start to see lots of log messages on screen. Using your iOS/Mac/iTunes/Airfoil/other client, you should now see new AirPlay devices and can try to play audio to them.

If it works, type exit, which terminates the executable, and then, on non-Windows/MacOS machines, relaunch it with -z so that it can run in the background and you can close the command line window. You can also start it automatically using any startup script or a Linux service as explained below. Nothing else should be required, no library or anything to install.

For each platform, there is a normal and a '-static' version. This one includes all libraries directly inside the application, so normally there is no dependence to 3rd party shared libraries, including SSL. You can try it if the normal fails to load (especially on old systems), but static linkage is a blessing a curse (exact reasons out of scope of this README). Now, if the static version still does not work, there are other solutions that are pretty technical, see here. Best is that you open an issue if you want help with that.

Common information:

<strong>Use -h for command line details</strong>

  • When started in interactive mode (w/o -Z or -z option) a few commands can be typed at the prompt
    • exit
    • save <file> : save the current configuration in file named [name]
  • Volume changes made in native control applications are synchronized with AirPlay client
  • Pause, Stop, Next, Prev using native control application are sent to AirPlay client - once paused, "native" play will not work
  • Re-scan for new / lost players happens every 30s
  • A config file (default config.xml) can be created for advanced tweaking (a reference version can be generated using the -i <file> command line)
  • Chromecast groups are supported. Use -v to set the media volume factor for all devices (0.5 by default)
  • use -c mp3[:<rate>]|aac[:<rate>]|flac[:0..9]|wav|pcm to set codec use for re-encoding audio
  • When you have more than one ethernet card, you case use -b [ip] to set what card to bind to. Note that 0.0.0.0 is not authorized
  • Use -u <version> to set the maximum UPnP searched version
  • Use -b [ip|iface][:port] to set network interface (ip@ or interface name as reported by ifconfig/ipconfig) to use and, for airupnp only, UPnP port to listen to (must be above the default 49152)
  • Use -a <port>[:<count>] to specify a port range (default count is 128, sets RTP and HTTP ports)
  • Use -g -3|-1|0| to tweak http transfer mode where -3 = chunked, -1 = no content-length and 0 = fixed (dummy) length (see "HTTP content-length" below)"
  • Use -N "<format>" to change the default name of AirPlay players (the player name followed by '+' by default). It's a C-string format where '%s' is the player's name, so default is "%s+"
  • Use of -z disables interactive mode (no TTY) and self-daemonizes (use -p <file> to get the PID). Use of -Z only disables interactive mode
  • <strong>Do not daemonize (using & or any other method) the executable w/o disabling interactive mode (-Z), otherwise it will consume all CPU. On Linux, FreeBSD and Solaris, best is to use -z. Note that -z option is not available on MacOS or Windows</strong>
  • A 'click' noise can be heard when timings are adjusted by adding or skipping one 8ms frame. Use -r to disable such adjustements (or use <drift> option in config file), but that might cause overrun or underrun on long playbacks
  • <strong>This is an audio-only application. Do not expect to play a video on your device and have the audio from UPnP/Sonos or ChromeCast synchronized. It does not, cannot and will not work, regardless of any latency parameter. Please do not open tickets requesting this (see details below to understand why)</strong>

Config file parameters

The default configuration file is config.xml, stored in the same directory as the <executable>. Each of parameters below can be set in the <common> section to apply to all devices. It can also be set in any <device> section to apply only to a specific device and overload the value set in <common>. Use the -x <config>command line option to use a config file of your choice.

  • latency <[rtp][:http][:f]> : (default: (0:0))buffering tweaking, needed when audio is shuttering or for bad networks (delay playback start)
    • [rtp] : ms of buffering of RTP (AirPlay) audio. Below 500ms is not recommended. 0 = use value from AirPlay. A negative value force sending of silence frames when no AirPlay audio has been received after 'RTP' ms, to force a continuous stream. If not, the UPnP/CC player will be not receive audio and some might close the connection after a while, although most players will simply be silent until stream restarts. This shall not be necessary in most of the case.
    • [http] : ms of buffering silence for HTTP audio (not needed normaly, except for Sonos)
    • [f] : when network congestion happens, source frames will not be received at all. Set this parameter to force sending silence frame then. Otherwise, no HTTP data will be sent and player might close the connection
  • drift <0|1> : enable adding or dropping a frame when case source frames producion is too fast or too slow
  • enabled <0|1> : in common section, enables new discovered players by default. In a dedicated section, enables the player
  • name : The name that will appear for the device in AirPlay. You can change the default name.
  • upnp_max : set the maximum UPnP version use to search players (default 1)
  • http_length : same as -g command line parameter
  • metadata <0|1> : send metadata to player (only for mp3 and aac codecs and if player supports ICY protocol)
  • artwork : an URL to an artwork to be displayed on player
  • flush <0|1> : (default 1) set AirPlay FLUSH commands response (see also --noflush in Misc tips section)
  • media_volume <0..1> : (default 0.5) Applies a scaling factor to device's hardware volume (chromecast only)
  • codec <mp3[:<bitrate>]|aac[:<bitrate>]|flac[:0..9]|wav|pcm> : format used to send HTTP audio. FLAC is recomm

Related Skills

View on GitHub
GitHub Stars4.0k
CategoryDevelopment
Updated2h ago
Forks240

Languages

C

Security Score

85/100

Audited on Mar 24, 2026

No findings