HOW-TO:Modify the video cache

From Official Kodi Wiki
(Redirected from HOW-TO:Modify the cache)
Jump to: navigation, search
Home icon grey.png   ▶ advancedsettings.xml
▶ Video library
▶ 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.


Note: Even if you change the cache settings in Kodi, that won't change how fast the video file data comes in over the network. For example, it won't make a slow server load the video any faster.


Note: PVR users will need to use different settings detailed on advancedsettings.xml#pvr.


Contents

1 Steps

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:
<advancedsettings>
  <network>
    <!--- The three settings will go in this space, between the two network tags. --->
  </network>
</advancedsettings>
3 Add some or all of the settings tags from the next section.
4 Save this file in your userdata folder:

Note: If you have an existing file, make sure the <network></network> tags, and settings we'll add between them, are between the main <advancedsettings></advancedsettings> tags.

Note: In older versions of the software (before v14) the kodi directories were named xbmc.
Operative system File path
Android Android/data/org.xbmc.kodi/files/.kodi/userdata/ (see note)
iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
Linux ~/.kodi/userdata/
Mac /Users/<your_user_name>/Library/Application Support/Kodi/userdata/ (see note)
LibreELEC/OpenELEC /storage/.kodi/userdata/
Windows Start - type %APPDATA%\kodi\userdata - press <Enter>


2 Cache settings

advancedsettings.xml tag what it does
<buffermode>1</buffermode> 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.

0 Buffer all internet filesystems (like "2" but additionally also ftp, webdav, etc.) (default)
1 Buffer all filesystems, both internet and local
2 Only buffer true internet filesystems (streams) (http, etc.)
3 No buffer
<cachemembuffersize>20971520</cachemembuffersize> Increasing the cache

Here we can do two things:

  • Value: 20971520 (or any value, in bytes) - keep the cache in RAM, but increase how much RAM is used. The number is the buffer size in bytes (20971520 is the default, which is 20MB, which requires 60MB of free RAM). Kodi will not buffer ahead more than this. Note: For the memory size set here, Kodi will require 3x the amount of RAM to be free. Setting this too high might cause Kodi to crash if it can't get enough RAM.

or

  • Value: 0 - we can use the local disk memory (typically your hard drive), which will not put any limit on the size (outside of the size of your drive). This also allows devices with low RAM, such as the Raspberry Pi, to cache more than they normally would due to the small amount of RAM they have. The cache is deleted from the local disk whenever playback is stopped. Note: This will likely cause increased wear-and-tear on your drive.


Note: Do not use the 0 (zero) setting if you have a device with a low amount of local storage, such as 8GB on a Fire TV. As a general rule of thumb, only use this setting if you have at least 16 GB of local drive space that is currently free on the device. Otherwise, Kodi will stall and stop playing the video, or might even crash.
<readbufferfactor>10</readbufferfactor> Increase the fill-rate of the cache

By default (value: 1), 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.


The value of this setting is a multiplier of the default limit. If Kodi is loading a typical bluray raw file at 36 Mbit/s, then a value of 2 will need at least 72 Mbit/s of network bandwidth. However, unlike with the RAM setting, you can safely increase this value however high you want, and Kodi won't crash. Just know that it might cause Kodi to attempt to use all available bandwidth on your HTPC during playback.

3 Kodi v17 changes

FUTURE Krypton FEATURE:

In Kodi v17, the following tags are removed from <network> and placed under a new <cache> tag. Also, <cachemembuffersize> is renamed to <memorysize> and <readbufferfactor> is renamed to <readfactor>.

<cache>
  <memorysize>0</memorysize>  <!-- number of bytes used for buffering streams in memory
   When set to 0 the cache will be written to disk instead of RAM -->
  <buffermode>0</buffermode>  <!-- Choose what to buffer:
    0) Buffer all internet filesystems (like "2" but additionally also ftp, webdav, etc.) (default)
    1) Buffer all filesystems (including local)
    2) Only buffer true internet filesystems (streams) (http, etc.)
    3) No buffer -->
  <readfactor>4.0</readfactor> <!-- this factor determines the max readrate in terms of readbufferfactor * avg bitrate of a video file.
This can help on bad connections to keep the cache filled. It will also greatly speed up buffering. Default value 4.0. -->
</cache>

4 Examples

4.1 Example 1

All three options enabled, using local hard drive for cache.

Stop hand.png Do not use this for flash-based memory devices.
advancedsettings.xml
<advancedsettings>
  <network>
    <buffermode>1</buffermode>
    <cachemembuffersize>0</cachemembuffersize>
    <readbufferfactor>30</readbufferfactor>
  </network>
</advancedsettings>

4.2 Example 2

Only cache size changed, using 100MB of RAM for cache (which requires 300MB of free RAM).

advancedsettings.xml
<advancedsettings>
  <network>
    <cachemembuffersize>104857600</cachemembuffersize>
  </network>
</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.xml
<advancedsettings>
  <network>
    <buffermode>1</buffermode>
    <cachemembuffersize>52428800</cachemembuffersize>
  </network>
</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.xml
<advancedsettings>
  <network>
    <buffermode>1</buffermode>
    <cachemembuffersize>139460608</cachemembuffersize>
    <readbufferfactor>20</readbufferfactor>
  </network>
</advancedsettings>

5 See also

Personal tools
Namespaces

Variants
Actions
Navigation
Wiki help
Toolbox