v17 -  buffering issues - is this a bug, or is this intended or am i doing something wrong?
Hi all,

if I did understand correct the following settings in my advancedsettings.xml file should do the following:
  • Load local and remote (internet) files into the buffer.
  • The buffer should have 33 MB
  • The buffer should fill up very quick, compared to what would be needed to achieve a smooth playback.
  • This should happens regardless if it is a video or an audio file.
[email protected]:~ $ cat .kodi/userdata/advancedsettings.xml

If this is true, than I have encountered the following issue when I play audiofiles:
  • Depending on my connection-setup (sshfs or sftp/ssh) the Buffer will be used or not used.
  • Depending on my connection-setup (sshfs or sftp/ssh) the music will lag / stutter during playback or not lag / play smooth.

I try to stream my audiofiles that I have on my server at home, to the actual place where I am now.
To create a connection to my homeserver I use openVpn.
When the vpn-connection is established I have two options on how to connect to my audio-folder:

Option A) I could run sshfs to mount my remote audio folder as if it would be a local folder. Inside Kodi than I would have to integrate that local folder to my Music library.


sshfs -p 2202 [email protected]:/home/alex/Music-HDD/ /home/pi/media-fs/musik/ -o IdentityFile=/home/pi/.ssh/id_rsa,reconnect,Ciphers=arcfour
[email protected]:~ $ ls media-fs/musik/
Allg  Cybercrime Podcast  eigene Sets  tacklist Jan 2018.txt  Techno  toBurn2  Tracksammlung  Traktor  Traktor Configs and Setups
Option B) I could run Kodi and integrate a remote folder using the sftp/ssh option.


Using option A) [sshfs]

Via the Kodi menu I navigate to an audiofile that is bigger than the specified buffersize.
For example I choose a *.flac file that is greater 400MB and press play.
At the beginning (I don't know exactly how long, lets say 1 minute) the audio plays smooth without any lag.
Than after a short period of time the audio begins to stutter / lag.

The following is what I observe when using bmon on tun0 while the music plays:
At the beginning of the audioplayback the downloadspeed is about as high as it can be when maxed out (about 2.5 to 3 MB per second). When it reaches the buffer amount that I have specified of about 33MB the downloadspeed drops to zero.
(Downloading with max speed until buffer is full than drop to zero)

Until now the playback is fine, and without any stuttering. I guess this is because a portion of the audiofile has been loaded into the buffer and now it is just playing what is left in that buffer.
After a short period of time, the audiofile begins to stutter - because the buffer is empty I guess - and the downloadspeed increases from zero speed to a very low and inconsistent one.
(Buffer empty, audiofile stuttering, reinitiate downstream at low speed and inconsistent)

Using option B) [sftp/ssh]

Via the Kodi menu I navigate to an audiofile that is bigger than the specified buffersize.
For example I choose a *.flac file that is greater 400MB and press play.
The audiofle plays smooth. No stuttering / lag.

The following is what I observe when using bmon on tun0 while the music plays:
At the beginning (about one to two minutes) the downloadspeed is about 450 KiB/s. After a little while it drops to zero. Than it restarts and and is at a consitent downloadspeed of about 113 KiB/s.

(Downoadspeed about 450 KiB/s than drops to zero)

(Downoadspeed from zero increase to about 113 KiB/s)

This in contrast to when I play a videofile behaves in the exact opposite manner.
I press play on a videofile that is bigger than the specified buffersize (a file greater 10GB for example).

Using option A) when playing videos results in a smooth playback and and high downloadspeeds.
(Filling buffer at max downloadspeed (about 3MB/s), than drop to constant downloadspeed (about 1MB) to achieve smooth playback)

Using option b) when playing videos results in a stuttering / laggy playback and low downloadspeeds.
(Constant download speed at about 450 KiB/s - video stuttering frequently)

  • To me it looks like the buffer is not properly used when using option A). it seems that the buffer, once it has been filled it is not going to be refilled anymore.
  • When using option B) it might be that the buffer is properly implemented but the downloadspeed is limited to only 450 KiB/s.

  • Is this a bug, or is this behaviour intended, or am I doing something wrong?
  • What do i have to do that the buffer is used the same way when playing video using option A?
  • What do I have to do to increase the downloadspeed when using the sftp/ssh option B?

ps: If you want me to create logs, tell me to do so, and I take the time to do them too. One for each scenario.

My Specs:
Raspberry Pi 3
Kodi 17.6
Raspbian / Debian 9 Stretch

[email protected]:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION="9 (stretch)"

[email protected]:~ $ uname -a
Linux raspberrypi 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l GNU/Linux

[email protected]:~ $ /opt/vc/bin/vcgencmd version
Jul  3 2018 14:15:46
Copyright © 2012 Broadcom
version 47b05c853342eb6e4ea5b017d981e0ef247fb8be (clean) (release)

[email protected]:~ $ ssh -V
OpenSSH_7.4p1 Raspbian-10+deb9u3, OpenSSL 1.0.2l  25 May 2017

[email protected]:~ $ sshfs -V
SSHFS version 2.8
FUSE library version: 2.9.7
fusermount version: 2.9.7
using FUSE kernel interface version 7.19

Best wishes,
Thank you for the detailed information, but unfortunately I know nothing about buffering and can't help you. I had hoped that someone that did would reply, but that has not happened. I will try to get the attention of the player guys, but they are quite busy with v18 Beta at the moment
My knowledge about how Kodi buffers media is also limited, I think I never tried <buffermode>1</buffermode>. The only change that I make to advancedsettings is <memorysize> which I increase a little bit to 32MB because the default 20MB was not enough to play smooth some big internet streams. And by big I am talking of 10GB+ video files.
One thing that doesn't make much sense to me is connecting to a VPN and mounting a filesystem on the same remote network with sshfs/sftp. With this you are encripting things two times, there is no need for that, just one way should be enough. And as you probably know, the RPi is not very good at encrypting/decrypting things. I sometimes also use VPN to connect to my home network, but then, I mount filesystems with NFS or Samba.
Thread Rating:
  • 0 Vote(s) - 0 Average

Logout Mark Read Team Forum Stats Members Help
buffering issues - is this a bug, or is this intended or am i doing something wrong?00