mpv icon indicating copy to clipboard operation
mpv copied to clipboard

OS X files on network shares (afp/smb) not cached

Open ghost opened this issue 12 years ago • 15 comments

Files played from network shares (AFP and SMB shares tested on Synology NAS) don't use cache by default, resulting in choppy playback.

A temporary workaround is to put cache=8192 in ~/.mpv/config. cache-default=8192 does not fix choppiness. Possible regression since I didn't notice this problem until very recently.

ghost avatar Feb 16 '14 12:02 ghost

mpv has no clue that these files come from the network, unless you access them directly using smb://, ftp:// or http:// for example, and not through the filesystem.

Only thing you can do it to manually or always enable the cache.

ChrisK2 avatar Feb 16 '14 12:02 ChrisK2

@ChrisK2 filesystem type for given file can be determined programatically using statfs

For example:

#include <sys/param.h>
#include <sys/mount.h>
#include <stdio.h>

int main (int argc, char *argv[]) {
  struct statfs fs;
  if (statfs(argv[1], &fs) == 0) {
    puts(fs.f_fstypename);
  }
}
$ cc -o statfs statfs.c
$ ./statfs ~/video.mkv 
hfs
$ ./statfs /Volumes/Media/video.mkv
afpfs

ghost avatar Feb 16 '14 12:02 ghost

Hm, I guess that could be implemented then.

ChrisK2 avatar Feb 16 '14 13:02 ChrisK2

I second that request.

Similarly, always enable caching on non local UNC paths on windows, and network fs (anything fuse except encfs/ecryptfs/ntfs3g too) on Linux.

statfs exists on Linux too, but returns a weird fs id on linux.

I can volunteer for doing the Linux implementation of this. Will help sshfs users a lot. Am 16.02.2014 14:02 schrieb "ChrisK2" [email protected]:

Hm, I guess that could be implemented then.

Reply to this email directly or view it on GitHubhttps://github.com/mpv-player/mpv/issues/558#issuecomment-35196145 .

divVerent avatar Feb 16 '14 15:02 divVerent

Keep in mind that statfs is entirely, and you'll probably have to add a few configure checks.

Streams can request cache with setting stream->streaming = true;.

ghost avatar Feb 16 '14 16:02 ghost

Keep in mind that statfs is entirely,

I meant to write entirely non-portable.

ghost avatar Feb 16 '14 16:02 ghost

Yes. On Linux one might even have to use /proc/mounts to get a useful fs name. When the OS X variant is there, I'll tackle Linux.

divVerent avatar Feb 16 '14 16:02 divVerent

+1. This seems like a good idea.

For a Windows implementation, it looks like GetDriveType is the way to go: https://gist.github.com/rossy2401/9044827

rossy avatar Feb 17 '14 04:02 rossy

Hello, I implemented it for BSD/OSX in the remote-volumes branch.

pigoz avatar Feb 17 '14 11:02 pigoz

Hello, I implemented it for BSD/OSX in the remote-volumes branch.

OK, look as nice as such an ifdef party could possible be made look nice.

One small suggestion: maybe let the check_stream_remote function return whether the stream is suspected remote or not, instead of setting stream->streaming in platform specific code.

Also, I wonder if it would be better to just pass the path instead of the stream ptr to that function. On the other hand, the stream could for example be used to check the file handle directly instead of the path (if one of the plsatform APIs allows this).

ghost avatar Feb 17 '14 17:02 ghost

One small suggestion: maybe let the check_stream_remote function return whether the stream is suspected remote or not, instead of setting stream->streaming in platform specific code.

I didn't want to overengineer it but you are right. It's better to immediatly abstract away the platform independent parts. Will change that.

pigoz avatar Feb 17 '14 17:02 pigoz

As for the passing stream, it's probably needed on Windows. On BSDs I just realized there is fsfstatfs which takes a fd instead of a path.

pigoz avatar Feb 17 '14 17:02 pigoz

pushed the BSD implementation to master ^

pigoz avatar Feb 17 '14 18:02 pigoz

Seems to cache even when cache=no is set in my config. Really annoying since 10.9's smb implementation takes forever to start doing anything useful. I can copy a 6GB file in minutes but I can't stream it without lag. screen shot 2014-02-26 at 10 20 43 pm Pic related: the spots with no activity are the video playing back, and the spike in activity is when the video lags. If I understand caching properly, then that's essentially what mpv is doing despite my settings.

marlencrabapple avatar Feb 27 '14 06:02 marlencrabapple

You can check whether it's caching by looking at the terminal output. It'll print something like [cache] Cache size set to 320 KiB in the first lines.

Anyway, closing, since it's implemented for OSX and Win32, and nobody seems to care about the Linux case.

ghost avatar Mar 10 '14 22:03 ghost