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
).
free
-- so something interesting in your post is the fact that this number is relatively small. If you increase Kodi's to-disk cache, that number could/should increase while in action to about match it.