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. – goldilocks Jun 28 '15 at 18:10free
because the kernel won't actually do it, it will just pretend (this is the difference between "virtual" memory and actual RAM) and then provide it in small chunks as the application actually goes to use it. Hence, the basic method is reasonable, but it is also possible that Kodi incorporates a similarly complicated scheme itself, only asking for chunks when needed up to the maximum. – goldilocks Jun 28 '15 at 18:46top
(get the pid and usetop -p [pid]
so there's only Kodi shown) with various settings, paying attention to how theVIRT
andRSS
figures jump around. Another test, if feasible, would be to watch a stream from another box on the same local network, to see how smoothly that goes. – goldilocks Jun 28 '15 at 18:47top
on kodi. I set a 20MB buffer. Two videos on SFTP, for about 2 minutes: VIDEO that cause trouble (1GB x264 - ~650KB/s) and VIDEO that works well (3.5GB x264 - ~180KB/s). Pretty same figures for both, at start: VSZ: ~475M RSS: ~90M, while running: VSZ: ~505M RSS: ~100M. The main difference is how it moves during playing. With VIDEO , VSZ and RSS barely changes. With VIDEO , they both reduce (~10M). Then, VIDEO stops, and VSZ and RSS slowly go up (buffer I guess). – Gui-Don Jun 28 '15 at 21:46nethogs
for this. Also when you use an android remote called "kore" there is this 'i' (for information I guess) button that shows you some video overlay with logging information. This could prove handy. – Havnar Jan 22 '16 at 11:11