Posted on

Kodi Buffering Problems FIXED!!

The lights are down low. You’ve made some fresh popcorn. You’ve just sat down for your movie “date night” when….

Buffering…..

Buffering…..

Be honest: How many movie nights have ended because of that one little word?

What about this one?

“Cache Full: Cache filled before reaching required amount for continuous playback”

Kodi has a lot of options available in the settings screen, but there’s no way currently to change the cache size. So, are we just going to have to live with stuttering videos and buffering issues?

Right?

Nope. That would make for a pretty short article. :)

So, stick around and I’ll tell you about the advancedsettings.xml file and how to modify the Kodi cache.

What is cache?

Even if you’ve never heard the term “cache” before, that’s OK. You’re probably using it every day without even knowing it. Cache is any temporary data that is stored on a device so that it can get the data faster than you, the end user, can consume it. That way any interruptions in transmission quality or network speed won’t bring your video to a screeching halt.

Think of it like this. Have you ever been at a sports bar watching the same game on two TV’s, but one of the TV’s is slightly ahead of the other? Imagine one TV is “storing” a few extra seconds of the game, just in case there’s a problem with the signal.

Just for the record, that’s not why the TV’s are out of sync, but it makes it for a good analogy.

Types of Kodi Cache

There are several different types of cache memory that KodiXBMC uses during playback:

Video Cache

Video cache is exactly what it sounds like: cache used for playing back videos streaming from the Internet or somewhere else on your local network. Kodi will use system RAM in order to store a few seconds of the file. Since system RAM is the fastest type of storage available on just about any computer system, this is going to be your best performance option.

Since Kodi is designed for systems with as little RAM as 1GB, it doesn’t use much RAM for video cache by default – usually about 60MB. This cache is used, as needed, and then cleared after each use.

This is the type of cache that I’ll be showing you how to configure later in this article. If you have network speed issues, or a troublesome Wi-Fi connection, this will be your best bet for improving Kodi video playback problems.

Add-On Cache

Unlike video cache, which is a part of the base video playback code, some Kodi add-ons will have their own cache. Some may use this to supplement the video cache while other add-ons may ignore the video cache  completely and use their own.

The trouble with this form of cache is that the add-on has to do a good job of keeping track of it and cleaning it up. If it doesn’t, then those temporary files will sit on your device, taking up valuable space. To delete add-on cache, you’ll need to navigate to each individual add-on folder and delete files manually.

The addon data folder will be in a subfolder in your userdata directory. Where these folders are located will depend on your system’s operating system:

OPERATING SYSTEM FILE PATH
Android Android/data/org.xbmc.kodi/files/.kodi/userdata/
iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
Linux ~/.kodi/userdata/
Mac /Users/<your_user_name>/Library/Application Support/Kodi/userdata/
OpenELEC /storage/.kodi/userdata/
Windows Start – type %APPDATA%kodiuserdata – press <Enter>

Remember that older versions of Kodi (before version 14) were called XBMC. If you’re still running one of the older versions and can’t upgrade, replace Kodi with XBMC where you see it in the chart above.

Android Application Cache

How to clear Kodi Android app cacheI’m sure I don’t have to tell you that pretty much every Android application has it’s own cache.

This will usually be the easiest to clear, because it’s the one that we’re most familiar with.

To clear the Kodi Android application cache, or any other Android app cache, go to your Settings menu and select “Apps”. Scroll down to find the app you’re looking for and click on it. There will almost always be a button that says “Clear Cache” in it’s settings screen.

Unlike a lot of other Android apps, you won’t need to use this method very often. In reality, you should only ever have to manually clear the Kodi cache through the Android Settings screen when Kodi crashes unexpectedly. If it’s not able to remove cache files automatically or a file gets corrupted, this should be one of your first steps to troubleshoot.

This won’t lose any settings that you’ve entered, but it will give you another chance to see those “Kodi is running for the first time” screens that we all know and love.

Click here to find out about Kore: The official Kodi Remote App!

Image Cache

Have you ever looked at how much space is taken up by your image thumbnails? When you think about how small an image is, it doesn’t seem like much. Most images are anywhere from 500Kb to 5MB in size, depending on the resolution. Occasionally you’ll come across uncompressed images which are larger than 5MB, but they’re rare. So what’s the big deal?

Well, when you’ve got a collection of music and movies that you’ve been accumulating for years, those little files can add up. For example, I’ve ripped every single CD I’ve ever owned to my NAS (Network Attached Storage) – over 1100 CD’s! If each one has a 1MB image attached to it, that’s over 1GB! Imagine finding space for another 2 movies on your device, simply by managing your Kodi image cache better.

Temp Files

Temp files – the bane of my existence. Well, at least as far as my PC goes.

I’ll bet that you’ve got at least one or two ‘Temp’ directories on your PC just overflowing with useless files that some program should have uninstalled, but didn’t. Kodi has the same problem sometimes. Whether its the leftovers from a Zip file installation or remnants of some add-on that wouldn’t leave – you can recover some space by cleaning them out.

Why bother?

It’s simple, really. The more space you have, the more you can set aside for buffering videos, and isn’t that why you’re reading this article?

Now that you know what cache is, let’s fix those pesky “Kodi cache full” messages. To do this, we’ll create an advancedsettings.xml file.

What is advancedsettings.xml?

Advancedsettings.xml is a file that stores all of the user-created settings for your Kodi installation.

Remember, Kodi is an open-source project that started out as a media center that would only work on a modified Xbox. Tweaking has been part of KodiXBMC’s DNA since the very beginning.

Does that mean that this is going to be hard? Not at all.

I’ve created a sample advancedsettings.xml file that you can drop in your Kodi folder. You can either download it from the link below, or, if you’re more “hands on”, I’ll show you how you can create your own.

Framework (and a brief description of XMLHTML tags)

The basic framework of the advancedsettings.xml file looks like this:
<advancedsettings>
<setting>value</setting>

<setting>value</setting>
</advancedsettings>

If this looks complicated, don’t worry. It’s not that bad. Besides, if you don’t want to stress about it, skip ahead to the download section and use my pre-made file.

Any XML (or HTML) file will always have an opening and closing tag for everything. Think of those tags as “framing” the important stuff – just like a picture frame. If you leave off one side of a picture frame, then the important stuff (the picture) winds up on the floor next to your cat. Its the same with XMLHTML tags, only without the cat. They usually don’t like programming.

If you look at the file from the top and bottom at the same time, you’ll see what I mean. The opening tag is the first <advancedsettings>. The closing tag will look almost identical, except for the forward slash in front: </advancedsettings>

On the inside, each setting will have its own opening and closing tags: <setting> and </setting>. The actual value is there in between the two.

You’ll replace the word “setting” with the actual name of the setting you want to change.

I’ll show you what I mean.

Settings you can change

Let me be clear up front, this is a brief look at the settings you can change in the advancedsettings.xml file. There are dozens of settings you can change to tweak your Kodi experience. We’re only looking at a few which are directly related to Kodi buffering problems. If you want the complete list, please check out theKodi Wiki page devoted to the advancedsettings.xml file.

Once you get started tweaking settings, you may find a number of other things that you could improve to really make your setup the best it can be. It can be fun!

Network

Not really a setting, but a “family” of settings. All three of the settings listed below will fall under the Network grouping. So we’ll have to include an opening <network> tag and a closing </network> tag.

Buffermode – The “what”

The first Kodi cache setting we’re going to look at is the Buffermode. Buffermode controls how Kodi uses the cache during playback. More specifically, it controls which files get buffered. This is the “what files” will get buffered.

It can have four settings:

SETTING EXPLANATION
0 This is the default value. This buffers all internet filesystems (http, ftp, webdav, etc.)
1 This buffers all filesystems, both Internet and Local
2 Only buffers true Internet file systems (http, etc.)
3 No buffer

On most devices that you’re going to find on this site, I recommend using Setting 1. This means you’ll be buffering streaming files and local files, including those on your network. If you’ve got your media store on an external hard drive or NAS, then this will buffer those files during playback.

Our first settings line will look like this:

<buffermode> 1 </buffermode>

Readbufferfactor – The “speed”

Readbufferfactor is the setting that controls how quickly Kodi will fill the cache. By default, it is set to “1”, which means that Kodi will only look ahead slightly to store what’s coming next. Think of this setting as the “speed” in which Kodi fills the buffer.

If your network is unreliable, slow or you have a fair amount of interference in your home, you’ll want to increase this value.

The setting value is a multiplier of the default limit. Kodi looks at the average speed that the video will play at. Higher resolutionbitrate videos will stream at a higher speed.

The default setting is usually pretty good. I recommend only a slight increase to 1.5.

If you make the other changes and still have issues, you can change this value to as high as 4. If you have a high amount of RAM in your device, you could go even higher than that.

Basically, you can increase this value as much as you want. Kodi won’t crash, but it may end up using all of the bandwidth you have in the device. At that point, you won’t see any improvement in increasing the number. You’ll also not be able to do anything else on your device while you’re watching a video.

This settings line will look like this:

<readbufferfactor> 1.5 </readbufferfactor>

Cachemembuffersize – The “How much”

Here is the important one. Cachemembuffersize is the “how much cache should Kodi use” setting.

This value is stored in bytes – not MB or even KB. Plain, old minuscule bytes of memory. That means the number in this setting is going to be very large. 

Also, the way the cache works, Kodi will actually use three times the amount of RAM that you enter in the setting. So if you only have 1 or 2 GB of RAM on your device, you’ll want to be careful with this setting.

Since there are a lot of options with this setting, I’ll illustrate some of the more common ones here:

If you have a low power device, like a Raspberry pi, set this number to 50MB (which uses 150MB of RAM):

<cachemembuffersize> 52428800 </cachemembuffersize>

If you have a device with a lot of memory, you’ll be at the other end of the spectrum. You can set this number to 150MB (which uses 400MB of RAM):

<cachemembuffersize> 157286400 </cachemembuffersize>

For most users, the folllowing setting should work just fine. Here, we’ll set this number to 100MB (which uses 300MB of RAM):

<cachemembuffersize> 104857600 </cachemembuffersize>

A word of warning: Kodi Zero Cache

Alternately, you could use “0” as your setting in cachemembuffersize. You’ll see a lot of articles about “Kodi zero cache” add-ons and tweaks. I don’t recommend 0 cache for most users – especially those of us that use Android boxes or HTPC’s with flash storage.

What zero cache does is write the entire file to disk for speedy viewing. What’s wrong with that, you ask? As I’ve detailed in this article, the flash storage, including Solid State Drives (SSD), has a finite amount of read-writes that it can perform before the drive just plain dies. No clicking like normal hard drives….just dead.

If you write the entire file of every song and movie you play to your internal storage you’ll burn through the life of that storage fairly quickly.

 Putting it all together…

Now that you’ve got a basic understanding of the advancedsettings.xml file and an idea of what settings would work for you, it’s time to put them all together into one file.

Using the settings I recommended above, we come up with this:
<advancedsettings>
<network>
<buffermode> 1 </buffermode>
<readbufferfactor> 1.5 </readbufferfactor>
<cachemembuffersize> 104857600 </cachemembuffersize>
</network>
</advancedsettings>

These settings should work for the majority of HTPCAndroid TV box users out there, but feel free to modify them if you feel you need to.

Creating (or downloading) the advancedsettings.xml file

Now that you have the settings you want, you have to get them into a file.

Create a new text file using notepad, Jota or any other text editor you choose. Then copy the settings above into that file and save the file at “advancedsettings.xml”.

Be sure that the file is saved exactly as above. A common error is that the file is saved as “advancedsettings.xml.txt” – that won’t do you, or Kodi, any good. Pick the right file extension!

Alternately, you can choose to download my pre-made advancedsettings.xml file here. Just remember to manually change the file extension from “.txt” to “.xml”: advancedsettings

How to install the advancedsettings.xml file

Now that you’ve got the file (with the correct extension), you’ll need to place it in your Kodi userdata folderon your device.

If you remember from the Add-on cache section at the top of this article, that will vary depending on your operating system. You can use that chart to navigate to your userdata folder with ES File Explorer, Windows Explorer or whatever file management application you prefer.

Wrapping it up

Hopefully this give you a better idea of what the advancedsettings.xml file is and how it can help you with Kodi cache problems.

SOURCE: http://androidpcreview.com/fix-kodi-buffering-problems-heres-how-to-modify-the-kodi-cache/2611/

Facebook Comments