Using Pi4 as a local cache for multiple Kodi Devices

What is the problem you are having with rclone?

Hi guys,

I want to setup a Pi4 (2GB RAM) as a local caching Device for my Kodi Players. The main Reason is, some devices like my Fire TV Stick are only connected via wifi, also the Kodi Addon for Gdrive is kinda slow / buggy. Thats why I want a local cache, for at least 4 Kodi Devices.

So I setup a Pi4, directly attached to the router. Added an 1TB SSD as cache drive, Mounted my Gdrive and created a NFSv4 Share. Downloads from Gdrive are fast, 500Mbit to the Pi.

Whats the Problem on the Kodi Devices?

  • listing the Gdrive Directory Structure is kinda slow (about 200 Folders)
  • Seeking in a ~ 8 GB Video File results in Kodi just closing the Video (playing from beginning works fine)
  • I feel like the vfs caching is not really working for me, there are files in the Cache folder, but performance is kinda bad, also directory listing is slow, am i using the wrong parameters?
  • Kodi starts to buffer for a few seconds sometime, even in 720p videos

I also tried to start rclone as an http Webdav server, but the problems were the same.

Not all Kodi Devices will stream at the same time, but i want to try to compensate any Wifi Problems, even thought all Devices are using 5ghz. Most files are 1080p or even 720p so it should be enough bandwidth.

Is there anything, i can do to optimize my buffering problems? Best scenario would be : Pi4 downloads the whole file, while the devices are streaming from the local cache. Directory structure gets fully cached, so switching back and forth is faster. Gdrive wont be updated much, so a long refresh time is no problem.
Any help would be great and sorry for the wall of text.

What is your rclone version (output from rclone version)


Which OS you are using and how many bits (eg Windows 7, 64 bit)

ARM - 64 Bit

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount gdrive: /GD --allow-other
 --dir-cache-time 1000h
 --poll-interval 3600s
 --vfs-cache-mode full
 --vfs-cache-max-size 700G
 --vfs-cache-max-age 3360h
 --vfs-read-chunk-size 128M
 --buffer-size 512M
 --log-level INFO --log-file /opt/rclone/logs/rclone.log

hello and welcome to the forum,

the mount can be primed before use. to download the directory/file structure.
for example, when i need my media server, jellyin, to search the mount for new media, i prime the mount, then have jellyfin scan.
to enable, that you need to add --rc to the mount command.
and run rclone rc vfs/refresh recursive=true

not a gdrive expert but gdrive supports polling, so i would use the default value.

my mount does not support polling and does not get updated a lot, so i use these values and prime as needed.
--read-only=true --dir-cache-time=0 poll-interval=0 --vfs-cache-mode=full

some rcloners do not use the vfs cache, as a test, i would remove that .

do you have a kodi device using a wired connection, not wifi, how does that perform?

gonna give that a try. Cant check the Kodi devices, while i am at work, but i took around 5 Minutes and resulted in

        "result": {
                "": "OK"

thanks, sounds good!

Another Pi4 is wired to a switch. Opening the NFS share also takes a few seconds, seeking is a problem too. So maybe my Kodi hardware is just too weak.

I´ll try to disable the caching completly, but i thought it would be a good idea to reduce API hits / bandwidth.
Thanks for the reply!

these are some simple steps to pinpoint the problem.

i have a PI4, and i setup a media server on it, using jellyfin media server.
jellyfin reads from the rclone mount and keeps a local database of the media.
clients access the jellyfin server, not the rclone mount
there is a kodi plugin.
jellyin can tweak the network settings for smooth playback

in this way, no need for NFS share. NFS might not work well with rclone mount.

You need to remove this parameter:

--buffer-size 512M

This means that for every file that Rclone opens, it allocates 512MB of RAM. As you only have 2Gb, as soon as you have four Kodi users, your PI will run out of memory. Leave it at the default (16MB) which is normally fine.

I would also remove these params:

--poll-interval 3600s

See how it goes now. You may also wish to experiment with --vfs-read-ahead. I have mine set to

--vfs-read-ahead 256M

which means, for the file being played, rclone will keep 256MB ahead in the cache, which helps to iron out any network glitches, and helps when skipping through a file during playback.

1 Like

yes, that is good advice.

this might be helpful,
Using Raspberry Pi for large data transfers

and this
Rclone Sync to S3 slow done to transfer errors to crash

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.