9

Every time I try to stream heavy (mostly 1080p) videos trough the network (webdav, sftp...), it either fails or I got the message “cache is full” etc. Videos start playing, but randomly stop (to buffer again, I guess).

I know this is a common issue and I know the the tweaks I can do (curl too).

The environment:

I use a RPi model B and I have a 100M/b internet connection. I’ve been testing with Kodi 14.2 and Kodi 15 (openelec 5.0.7, openelec 5.95.2).

The tests:

So far, among many additional options, this is what I tried:

Cache\Protocol | Webdav      | SFTP (local and internet)
--------------------------------------------------------------------------
No cache       | not loading | loads quickly, no error, stops frequently
--------------------------------------------------------------------------
(5mb cache)    | not loading | slow to load, cache error, stops randomly
--------------------------------------------------------------------------
(25mb cache)   | not loading | very slow to load, cache error, stops randomly
--------------------------------------------------------------------------
sdcard cache   | not loading | incredibly slow to load, no error, fine
--------------------------------------------------------------------------

Video problem?

Nope. If copied on the sd card, it runs smoothly.

RAM problem?

I would understand the hardware limitation if the RAM was full, but, while watching videos, free -m gives me this:

             total         used         free       shared      buffers
Mem:           373          236          137            4           34
-/+ buffers:                202          171
Swap:            0            0            0

It seems there are plenty available...

Interesting fact, as @goldilocks noticed, buffers is unusually low.

Network problem?

If I’m downloading a video file manually with SFTP, while playing this very same file at the same time, it works. Download speed: ~1.5MB/s. So, nor the network, nor the decryption is a bottleneck.

Other problem?

Errors in logfile (with video debug, ffmpeg debug), except debug and notices:

ERROR: CCurlFile::FillBuffer - Failed: Timeout was reached
ERROR: OMXPlayerVideo: Got MSGQ_IS_ERROR(-1) Aborting

OK, so curl is not optimised for video streaming. But what about SFTP? It should be a piece of cake.

Configuration problem?

The last test above (sdcard cache) is interesting. It start playing the video, after dowloading about 150M (!) on the sdcard (.kodi/temp/filecache000.cache). Although it runs well, it’s not a viable solution as it is too slow to start.

It seems to try to download the same amount of RAM, ignoring the configuration in advancedsettings.xml. I checked, the file is loaded without any issue. This is an exemple of something I tested (.kodi/userdata/advancedsettings.xml):

<advancedsettings>
    <network>
        <buffermode>1</buffermode>
        <cachemembuffersize>5242880</cachemembuffersize>
        <readbufferfactor>4.0</readbufferfactor>
        <curlclienttimeout>60</curlclienttimeout>
        <curllowspeedtime>20</curllowspeedtime>
    </network>
</advancedsettings>

Note: some of these options are not longer correct in kodi 17, see @ZacWolf answer for update

So, somebody has any idea? What could be wrong here? Whatever the solution, I also want to know why normal usage (RAM buffer) fails in this case.

EDIT: Test on Archlinux

I installed kodi on Archlinux, to determine if it’s a kodi or openelec issue. It’s the same: HD videos are choppy, so it seems to be a bug in kodi. It’s more like a protocol problem (SFTP and WebDAV: http) because my test with SSHFS works great. Unfortunately, it’s not trivial to install SSHFS on openelec.

EDIT 2: A workaround

I write it here, because it doesn’t directly address the buffering problem, but I have installed kodi on Archlinux for more than a year now, and it works perfectly well. It’s less noob-friendly than openelec, but for those who are interested:

  • Install Archlinux for ARM (very easy, just follow the guide - it’s for rpi1, for more recent one, just change the platform);
  • Install Kodi (follow the Archlinux wiki guide - basically, install kodi-rbp package);
  • Enable the kodi service to automatically run kodi on startup: # systemctl enable kodi.service;
  • Install SSHFS: pacman -Suy sshfs;
  • Use the very useful SSHFS automounting with /etc/fstab to mount your distant share.

Done. Don’t forget to update frenquently (pacman -Suy).

Gui-Don
  • 191
  • 1
  • 1
  • 6

3 Answers3

2

EDIT (12/2017)

Kodi v17 renamed and relocated tags in advancedsetting.xml

<cachemembuffersize> renamed to <memorysize>

<readbufferfactor> renamed to <readfactor>

AND they've been removed from <network> and added to <cache>

My advancesettings.xml now looks like:

<?xml version="1.0" encoding="utf-8"?>
<advancedsettings>
        <cache>
                <memorysize>524288000</memorysize>
                <buffermode>1</buffermode>
                <readfactor>6</readfactor>
        </cache>
</advancedsettings>
ZacWolf
  • 140
  • 5
1

I am running Pi 3 with OpenElec on it and I ran into lots of buffering issues as well.

I was streaming to it over Wi-Fi as I figured it was right next to the router and shouldn't have any issues. Well after plugging in via Ethernet I got to remove the advanced xml file all together as the buffering issues stopped.

My laptop and phone both play fine via Wi-Fi without buffering so something with the Pi 3's built-in Wi-Fi on OpenElec is causing the issue.

Darth Vader
  • 4,218
  • 24
  • 47
  • 70
Marcus
  • 11
  • 2
-1

I had the same problem and I used this 'hack', things run smoothly now.

--- edit --- Following @Simulant suggestion:

  • Install xunity maintenance tool.
  • Got into program (not settings), xunity - tweaks.
  • Select 'Add 0 Cache Advanced XML
Meir
  • 99
  • 2