An open-source implementation of an AirPlay mirroring server for the Raspberry Pi. The goal is to make it run smoothly even on a Raspberry Pi Zero.
Screen mirroring and audio works for iOS 9 or newer. Recent macOS versions also seem to be compatible. The GPU is used for decoding the h264 video stream. The Pi has no hardware acceleration for audio (AirPlay mirroring uses AAC), so the FDK-AAC decoder is used for that.
Both audio and video work fine on a Raspberry Pi 3B+ and a Raspberry Pi Zero, though playback is a bit smoother on the 3B+.
For best performance:
- Use a wired network connection
- Compile with -O3 (cmake --DCMAKE_CXX_FLAGS="-O3" --DCMAKE_C_FLAGS="-O3" ..)
- Make sure the DUMP flags are not active
- Make sure you don't use the -d debug log flag
- Make sure no other demanding tasks are running (this is particularly important for audio on the Pi Zero)
By using OpenSSL for AES decryption, I was able to speed up the decryption of video packets from up to 0.2 seconds to up to 0.007 seconds for large packets (On the Pi Zero). Average is now more like 0.002 seconds.
There still are some minor issues. Have a look at the TODO list below.
RPiPlay might not be suitable for remote video playback, as it lacks a dedicated component for that: It seems like AirPlay on an AppleTV effectively runs a web server on the device and sends the URL to the AppleTV, thus avoiding the re-encoding of the video. For rough details, refer to the (mostly obsolete) inofficial AirPlay specification.
Building
The following packages are required for building on Raspbian:
- cmake (for the build system)
- libavahi-compat-libdnssd-dev (for the bonjour registration)
- libplist-dev (for plist handling)
- libssl-dev (for crypto primitives)
- ilclient and Broadcom's OpenMAX stack as present in
/opt/vc
in Raspbian.
For downloading the code, use these commands:
git clone https://github.com/FD-/RPiPlay.git
cd RPiPlay
For building on a fresh Raspbian Stretch or Buster install, these steps should be run:
sudo apt-get install cmake
sudo apt-get install libavahi-compat-libdnssd-dev
sudo apt-get install libplist-dev
sudo apt-get install libssl-dev
mkdir build
cd build
cmake ..
make -j
GCC 5 or later is required.
Building on desktop Linux:
For building on desktop linux, follow these steps as per your distribution:
Ubuntu 18.04 or 20.04
sudo apt-get install cmake libavahi-compat-libdnssd-dev libplist-dev libssl-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav \
gstreamer1.0-vaapi gstreamer1.0-plugins-bad
mkdir build
cd build
cmake ..
make
Fedora 33
sudo dnf install cmake avahi-compat-libdns_sd-devel libplist-devel openssl-devel \
gstreamer1-plugins-base-devel gstreamer1-libav gstreamer1-vaapi \
gstreamer1-plugins-bad-free
mkdir build
cd build
cmake ..
make
Note: The -b, -r, -l, and -a options are not supported with the gstreamer renderer.
Global installation
After building, to install the executable on the system permanently (so it can be run from anywhere), simply run the following command:
sudo make install
Usage
Start the rpiplay executable and an AirPlay mirror target device will appear in the network. At the moment, these options are implemented:
-n name: Specify the network name of the AirPlay server.
-b (on|auto|off): Show black background always, only during active connection, or never.
-r (90|180|270): Specify image rotation in multiples of 90 degrees.
-f (horiz|vert|both): Specify image flipping.
-l: Enables low-latency mode. Low-latency mode reduces latency by effectively rendering audio and video frames as soon as they are received, ignoring the associated timestamps. As a side effect, playback will be choppy and audio-video sync will be noticably off.
-a (hdmi|analog|off): Set audio output device
-vr renderer: Select a video renderer to use (rpi, gstreamer, or dummy)
-ar renderer: Select an audio renderer to use (rpi, gstreamer, or dummy)
-d: Enables debug logging. Will lead to choppy playback due to heavy console output.
-v/-h: Displays short help and version information.
from https://github.com/FD-/RPiPlay
-----
MacOS airplay mirror receiver and simple player (For iOS 9,10,11)
AirplayMirror
Good luck
from https://github.com/openairplay/AirplayMirror
No comments:
Post a Comment