For a long time I was using Kodi with LibreELEC running on a Raspberry Pi 3 Model B device. It was pretty good, and I was going to write a post about it, but never had time for that, and now I got an Apple TV, so instead I’ll write a post about using Kodi on Apple TV.
I’ll talk about how to install Kodi on Apple TV and how to create a network media storage for it.
What’s wrong with Apple TV
Given its price, one would think that Apple TV should be able to do a lot of things and to have great media capabilities.
In reality, Apple TV as a media box is pretty much useless on its own. If you are not subscribed to the whole bazillion of TV services (Netflix, HBO, Hulu and many many more), then you will always be missing something (quite a lot of something), as TV shows are heavily scattered across TV providers and none has them all. It is fair to say that without subscriptions Apple TV is merely just an AirPlay host.
Certainly, you can buy or rent TV shows or movies in iTunes Store, but that will cost you a fortune, so it’s not really an option.
The conclusion here is that you need a proper video player - the one that could simply play your video files from wherever they are.
But that’s not all: Apple TV has a very limited internal storage. Basically, you won’t be able to store your movies and TV shows collection on it. Well, Raspberry’s case is even worse in that regard, but hear this - Apple TV does not support connecting external disk drives! And that means that the only option would be to set-up a network share, and play your videos from there.
The fuck then would you buy Apple TV for
So, what is the point in getting Apple TV at all? There is actually a couple of reasons.
First of all, it is actually quite a powerful device in terms of hardware, plus it has a very nice GUI and an unusual remote control (a bit retarded, but also nice).
AirPlay is also a quite nice thing to have, because the majority of devices and computers in the house are from Apple.
But mostly I got Apple TV kinda “for the future”: till the times I’ll have a 4K HDR Dolby Atmos telly, and also hoping that there will be finally a single streaming service containing all the movies and TV shows from all the networks - something I would gladly pay for.
Make Apple TV a better media box
Meanwhile, let’s try to make Apple TV to be more useful with what we have nowadays.
Set-up a network share
I reused the same Raspberry Pi device (the one that was my media player before) as the server. Since I’ve had it with all the limitations of LibreELEC, I formatted the card and put there Raspbian instead. And as the purpose of the device is just to share files from the connected external disk over the network, there was no point in having a desktop environment, so I took Raspbian Buster Lite.
Mounting external disk
I have an external disk drive, where I store my movies and TV shows collection plus downloads, and I wanted to use this disk as the main storage for Raspberry device.
For that it needs to auto-mount every time the device reboots and also it needs to mount to the same path. In order to do that, first you need to find its label (or UUID):
$ sudo blkid /dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5203-VC74" TYPE="vfat" PARTUUID="6c586e13-01" /dev/mmcblk0p2: LABEL="rootfs" UUID="2ab3f8e1-7dc6-43f5-b0db-dd1159d51l2e" TYPE="ext4" PARTUUID="6c586e13-02" /dev/mmcblk0: PTUUID="6c586e55" PTTYPE="dos" /dev/sda1: LABEL="somedisk" UUID="21V9-9819" TYPE="exfat" PARTUUID="ol37c326-01"
Create a mounting folder (it will also be your share):
$ sudo mkdir /media/somedisk
/etc/fstab like this:
LABEL=somedisk /media/somedisk exfat defaults,uid=1000,gid=1000,nofail 0 0
gid stand for user and group IDs - who will have access to the mounted path. By default, in Raspbian your user (
pi) has ID = 1000 for both itself and its group. You can check that with the following command:
Also, as you can see, my disk is formatted to exFAT, so I needed to install these as well:
$ sudo apt install exfat-fuse exfat-utils
Now the disk will be mounted automatically every time the system starts.
Sharing the files
What file sharing service/protocol to use?
For many years I was stumbling upon DLNA being mentioned here and there, implying that it is a widely known and adopted media sharing standard, so I thought it’s a good time to finally try it. I installed MiniDNLA, but to my surprise it did not get discovered by neither of media players (I tried Kodi, VLC and others).
Having wasted some time on trying to make it announce itself in a way someone would finally discover it, I got a seditious idea to just try SMB.
Install Samba and create user password (I went with default
$ sudo apt install samba samba-common-bin $ sudo smbpasswd -a pi
Edit the config:
$ sudo nano /etc/samba/smb.conf
[global] workgroup = WORKGROUP [share] Comment = MediaPi SMB Path = /media/somedisk Browseable = yes Writeable = no only guest = no create mask = 0644 directory mask = 0644 Public = yes Guest ok = no
Restart the service:
$ sudo systemctl restart smbd.service
And you know what? It just worked - the share immediately became discoverable from anywhere. So much for the media “standards”.
Why didn’t I use SFTP and went with Samba? Because I wanted to have SSH passwords disabled on my file server and allow connecting with SSH keys only, and Kodi on Apple TV sadly cannot use SSH keys (or I didn’t find a way).
What I didn’t know is that it is possible to enable using SSH password just for one user.
So when suddenly Kodi (and VLC too) stopped connecting to my Samba share (could recent tvOS update be the reason?), I just enabled SSH password for
$ sudo nano /etc/ssh/sshd_config Match User pi PasswordAuthentication yes
and then added my file server to Kodi with SFTP.
pi user here might seem not the best example, but actually later I’ve replaced Raspberry Pi with a proper PC and desktop Ubuntu, and there
pi user was created with very limited rights.
By the way, my seedbox also allows connecting to it via SFTP, so now I don’t even need to download files to my local server (though I’ll still talk about it below).
Downloading new files
Okay, you can share existing files from the disk, but how to put new files to the disk?
If you are from a country that doesn’t care much about you stealing media content via torrents, then I guess you can just install a torrent client (although I would first think about your disk resource first). And if you are from a Germany-like country, then most likely you are using a seedbox and are downloading files from it via SFTP/FTPS.
One way would be to download files to your computer first and then upload them to Raspberry via the very same SMB (or, better yet, via SFTP), but wouldn’t it be faster to download files directly to Raspberry without this intermediate step?
It definitely would, if only there was some remote GUI for that, because doing this via CLI is not so convenient.
And there is at least one such tool - rclone. It’s great for transferring files, and also it has a web-based GUI, so you can control it from your computer remotely, while all the downloads will happen directly on Raspberry.
Install rclone and config it with two remotes: one for your actual source of downloads (a seedbox, some server, some cloud storage, whatever) and another for your external disk. Here’s my config, for example:
[seedbox] type = sftp host = some.seedbox.io user = some pass = some md5sum_command = none sha1sum_command = none [disk] type = local
The reason you need to add the disk as a remote is that without it rclone will map
/ path to
/home/pi/, so downloads will go to SD card instead of the disk. I have no idea why is that.
Here’s how to launch rclone with web GUI:
$ rclone rcd --rc-web-gui --rc-addr :8998 --rc-htpasswd /home/pi/.htpasswd
apache2-utils and provide a password of your choice:
$ sudo apt install apache2-utils $ htpasswd -c /home/pi/.htpasswd
Now open http://PASPBERRY-IP-ADDRESS:8998 in your browser, enter login/password and here’s what you should see in the files explorer:
To start a download just drag and drop files/folders from the remote to your disk.
Works fine, however there are some pretty annoying issues:
- what’s the point of checkboxes next to files, as there are no group operations;
- by the way, it wouldn’t hurt to be able to select several files and drag and drop all of them to start the download. At the moment you have to drag and drop them one by one;
- when you add several downloads, all of them are downloading in parallel, as there is no queue;
- there is no way to cancel ongoing downloads;
- it is unclear what Load Media button does;
- floating Progress window doesn’t show anything;
- files are sorted alphabetically and you can’t sort them otherwise;
- one wrong move and files are downloading in your browser.
Hopefully, those will be fixed eventually, especially given that the whole project started not that long ago. Meanwhile, I’ve created my own web-interface for the task (I’ll write a separate post about it some time later).
Another more serous issue with rclone itself is that the download speed endlessly decreases right from the download start till it reaches some ridiculously low values, while the actual download never progresses past a couple of megabytes. Apparently, it has something to do with relatively recent changes regarding threads, because providing
--multi-thread-streams 1 option solves the issue.
One last step is to create a systemd service for rclone running with web GUI:
[Unit] Description=rclone web GUI [Service] WorkingDirectory=/home/pi ExecStart=rclone rcd --rc-web-gui --rc-addr :8998 --rc-htpasswd /home/pi/.htpasswd --transfers 1 --multi-thread-streams 1 Restart=always RestartSec=10 SyslogIdentifier=rclonewebgui User=pi [Install] WantedBy=multi-user.target
There is at least a couple of promising media players in the App Store, but they cost around 10 USD per year (or 60 USD for a lifetime license), which is a rip-off.
There is also VLC, and it is available for free, however I don’t like its GUI and media capabilities (from my experience with its desktop version). Although, to be fair, VLC can actually serve the purpose, because it supports reading files from network share plus it provides its own service for uploading videos from computer.
But why bother with all that when there is Kodi - the best thing to have as a media player on a TV box.
Unfortunately, it is not available in App Store. Fortunately, you can install it on Apple TV yourself. It’s the same thing as with iOS devices - as a developer you can install anything you want on your device (goes without saying that you’ll need a Mac for that).
Here’s the instruction with all the details, and here I’ll only list a short version of the process:
- Get an Apple Developer account;
- Add it to Xcode;
- Create a new project for tvOS - this is only needed to generate a provisioning profile, nothing else. Refer to the detailed manual from the link above for how to do that. The most problematic part for me was setting the Bundle Identifier as I felt smart-ass and chose a non-
- Download Kodi binaries for tvOS. Regrettably, it is not being updated for quite a while now, and the latest build is from 27.02.2018, but it still works fine;
- Download iOS App Signer;
- Launch iOS App Signer, choose
.debbundle you downloaded at the step 4, select Signing Certificate from your Apple Developer account, select Provisioning Profile you generated in Xcode at step 3 and sign the bundle;
- Upload signed
.ipabundle to Apple TV.
And it’s all good, except for one sad little detail - basic (unpaid) Apple Developer account allows you to create provisioning profiles that are valid for only 7 days, so you’ll have to repeat steps 3 (just open the same project and check the provisioning profile), 6 and 7 every week. When I get annoyed enough, I’ll try to find a way to automate that.
How to upload an application to Apple TV
Open Devices and Simulators in Xcode. If your Apple TV has a cable connection, everything should be straightforward for you, but in my case it is an Apple TV 4K version, so the only way to connect to it is wirelessly.
To make an Apple TV discoverable, open Remote App and Devices in its Settings:
Then you should be able to initiate the pairing process from Xcode. After it’s paired, just click on
+ button in the Installed apps section and upload the
.ipa file to Apple TV:
After that Kodi application should appear on your Apple TV:
Here’re also screenshots with system information from Kodi:
Connect to network share from Kodi
Finally, everything is ready to work together.
Add your SMB share to Kodi:
WORKGROUP and it will discover your Raspberry share automatically. Choose a folder and add it as a source:
Now you’ll be able to navigate it like a local filesystem and open any video file you put there.
…And rolled back to the old one because of the following issues with the new one:
- it is slow/laggy and poorly optimized
- Siri remote control works quite badly: hypersensitivity and glitches
- it couldn’t automatically discover or manually add my Samba share as a source
- also I couldn’t delete this failed source from the list as there is suddenly no context menu
- it did not pick up my existing settings (moreover, it fucking ruined them, so when I rolled back to the old version, I had to set everything up again)
- there is no clicking sound for menu actions
- they say you need to have a paid Apple Developer account for the Top Shelf feature now. Lolwut, it was working just with fine before
And the good old
kodi-20180227-4a25e62-yab-tvos.deb has none of these issues. So what was the point of the new build?
I saw that there are a lot of new releases available and decided to try the latest. I tried the following 3 (so you can already tell that it didn’t go well):
This time they did not ruin my settings, so that’s already some progress, however all 3 had these issues:
- still Top Shelf feature is not working. I don’t really need it, but that’s just amusing how two years old version has it and the latest ones don’t
- still no clicking sound for menu/navigation actions
- now it couldn’t connect to any of my SFTP shares, which renders the whole application useless
Needless to say, reverting back to the reliable
kodi-20180227-4a25e62-yab-tvos.deb made things right again.
Oh well, I’ll check again another half-year later.
I gave new versions another chance, now I tried these ones:
Still the fucking same results:
- still no Top Shelf feature, but this time they had a note in documentation, claiming that it only works if you have 99 USD paid Apple Developer account. How come then it works with
kodi-20180227-4a25e62-yab-tvos.debrelease without paid account?
- still no clicking sound for actions;
- still can’t connect to SFTP shares;
- plus now it’s also sluggish and less responsive even while simply navigating the main menu.
I made some more backup copies of the good old