HOW-TO:Modify the video cache
|HOW-TO:Modify the video cache|
This page describes three advancedsettings.xml settings that can be used to maximize the video playback cache. You can use all or just a couple of these settings to see significant improvements in cache performance, should you require it (most users will not require these modifications). This can help with intermittent network issues, buffering, reduce how long the network is tied up, and sometimes improve battery life.
If you don't already have an advancedsettings.xml file, it's very simple to make. Kodi uses this file for advanced settings and features that normal users shouldn't modify without first knowing what they do, as well as for experimental features, etc.
|1||Since you can use all or just some of the following settings, let's start out with the basic file. Create a plain text file (no rich text formatting, don't use .doc, etc) and save it as advancedsettings.xml. Make sure that the file extension is ".xml" and not ".txt" or ".xml.txt".|
|2|| Cut and paste this into your new plain text file:
|3||Add some or all of the settings tags from the next section.|
|4|| Save this file in your userdata folder:
2 Cache settings
|advancedsettings.xml tag||what it does|
|| Choose what to buffer
This setting will force Kodi to use a cache for all video files, including local network, internet, and even the local hard drive. Default value is 0 and will only cache videos that use internet file paths/sources.
|| Increasing the cache
Here we can do two things:
|| Increase the fill-rate of the cache
By default (value: 4), Kodi will only fill the cache a little above what is needed to play it back. It does this as to not max out your network and possibly max out some hardware. For most users and hardware, this setting shouldn't cause any issues, but be aware of it if you have unusual CPU spikes in your HTPC.
3 Kodi v17 changes
In Kodi v17, the cache-related tags were removed from
<network> and placed under a new
<cache> tag. In addition, the following tags were renamed:
<cachemembuffersize>was renamed to
<readbufferfactor>is renamed to
These are just examples to explain how the feature works. Most users will just want to use example 4.
4.1 Example 1
All three options enabled, using local hard drive for cache.
|Do not use this for flash-based memory devices.|
<advancedsettings> <cache> <buffermode>1</buffermode> <memorysize>0</memorysize> <readfactor>30</readfactor> </cache> </advancedsettings>
4.2 Example 2
Only cache size changed, using 100MB of RAM for cache (which requires 300MB of free RAM).
<advancedsettings> <cache> <memorysize>104857600</memorysize> </cache> </advancedsettings>
4.3 Example 3
Two options enabled, using 50MB of RAM for cache (which requires 150MB of free RAM), and cache both internet, LAN, and local content.
<advancedsettings> <cache> <buffermode>1</buffermode> <memorysize>52428800</memorysize> </cache> </advancedsettings>
4.4 Example 4
A safe setting for most devices with 1GB of RAM that should help most users "on the edge". All protocols get cached, cache rate fills up pretty much as fast as possible, and cache size is about 133MB, using about 400MB of ram total.
<advancedsettings> <cache> <buffermode>1</buffermode> <memorysize>139460608</memorysize> <readfactor>20</readfactor> </cache> </advancedsettings>
4.5 Example 5
If you want a setting that has a huge buffer that fills FAST as quickly and similarly to example 1 BUT you do not want it to write to hard disk, and instead would like it to write to RAM memory. Also some of the documentation states that the amount defined in memorysize will actually consume 3x as much RAM memory, but I have found in my testing that is not exactly the case, you may need to adjust memorysize a little and monitor how much of your system memory it consumes.(on linux you can use htop) The amount I have defined is roughly 4.2GB for memorysize, however on my system Kodi is consuming about 3.9GB, my system has 8GB ram so this is easily handled.
<advancedsettings> <cache> <buffermode>1</buffermode> <memorysize>4289999999</memorysize> <readfactor>1000</readfactor> </cache> </advancedsettings>