How to limit the number of open files for the Plex Scanner?

I wonder, how do I limit the number of open files that the Plex Scanner utilizes?

I am using Plex with plexdrive and when multiple parallel file accesses are done, it ruins playback performance.

If the scanner could be limited to only use ie. only 2 open files at a time, that would allow for playbacks working at the same time as scanning.

Right now it will happily open maybe 40 or more files, and it ruins all chances for playback of other media files when the scanning runs.

I don’t care that the scanning runs over several days or weeks - what I care about is being able to watch media files at the same time :slight_smile:

If it cannot be set in the Plex configuration options can something like the Linux utility “prlimit” be used for the purpose, perhaps? (I am running the server on Ubuntu).

My understanding is rclones VFS with cache should prevent this from being a problem. Any particular reason your still using plexdrive?

If I may?

The nature of the problem is not how many files are open, it’s the rate at which they are opened. PMS does them one at a time… It just does it VERY quickly.

As stated by Paradon55, rclone mount with caching does significantly reduce the API calls. Your risk of being trottled because you have a large library to scan is greatly, usually completely, reduced

The problem for me is not about being blocked from google drive.

The problem is about playback while scanning being impossible.

To reproduce:

  • Add a new TV Shows library, with content stored on Google drive - it can be mounted using plexdrive or rclone VFS with cache, it does not matter in my experience. TV shows with lots of seasons (10-20) makes the problem the most obvious for some reason.

  • Make sure generation of video preview thumbnails are enabled both in server settings, and for the library

  • Add the library

  • While the library is being scanned and video previews are being generated, watch the number of open files on the filesystem and try to playback newly added content from the library.

You control the scanning in Settings - Library

Thank you, ChuckPa.

Which settings in Settings - Library du you recommend I control, to solve my problem?

Of primary interest to you is “Partial Scan” . It will only scan that which it sees has changed.

It will make a pass of each Top level directory and the 2nd (“Season xx”) level of Series.

For 1000 movies in 1 library, = 1 directory read
For 1000 series in 1 library, each with 7 seasons = 1000 reads (to see if any seasons updated).

That should be much more tolerable. (1001 versus 7000 without using partial)

Thank you for the suggestion.

I have done some experiments with the Partial Scan (“Run a partial scan when changes are detected”) option now.

It doesn’t seem to make any difference at all.

Playback still halts while the scanning is ongoing.

I have no further suggestions. Sorry

Thank you for your help, ChuckPa.

I am now pursuing a strategy where I am using “find” to find the latest files since the last time it was run, then kicking in a scanning script manually for each item it finds.

I am thinking, this should allow me to put a proper delay between each add, keeping playback disturbance at a minimum.

But alas, I cannot figure out how to get the “–file” parameter for the “Plex Media Scanner” utility to work:

So far, I get either the error: “Error: Cannot select a file and something else.”

> plex@plex:~$ export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
> plex@plex:~$ /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --refresh --section 69 --file /plex/movies/A/Annie\ Hall\ \[1977\]/Annie\ Hall\ \[1977\].avi
> Error: Cannot select a file and something else.

Or, the error “Error: Invalid item list.”

> plex@plex:~$ /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --refresh --file /plex/movies/A/Annie\ Hall\ \[1977\]/Annie\ Hall\ \[1977\].avi
> Error: Invalid item list.

Any ideas?

plex_autoscan is your friend.

Thank you, danjanes92!

I have now tried plex_autoscan also.

I think it works fine for what it is intended for - but alas, it kicks off the scanner with a whole directory each time.

And then I am back to my original problem, that when the scanner sees for instance a new season of a TV Show with a number of files in it, it will open up these files at once … and playback is impossible while the operation lasts.

Have you perhaps had any success with the “–file” parameter, danjames92?

I can’t speak for rclone because I do not use it. I’m still on plexdrive myself. There are options for rclone inside plex_autoscan where it will kick off the refresh automatically.

If plex is locking up I’d say look at your rclone settings. You want to be using VFS.

Thank you, danjames92.

As I already mentioned, I get the same behaviour with rclone VFS. I am simply not able to see any difference in my tests.

Regarding my question about the “–file” parameter, it is not for plexdrive; it is for the “Plex Media Scanner” utility.

I am not sure you can actually add files this way, I think you could only refresh an existing file with the --file parameter.

I could be wrong, but am pretty sure that the way the scanner works, is that when scanning it looks in a directory and then adds and scans the files that it finds in the directory.

blim5001: That makes two of us, I am not sure of anything either :slight_smile:

Could you perhaps give me an example of a command line that refreshes an existing file succesfully?

The documentation says the “–scan” parameter will scan for new media, but just getting it to refresh an existing file would be great.

“-s, --scan Scan for new media.”

… just to see it work :slight_smile:

ha, had a play and nope cannot get it work with the --file parameter, had a bit of success using the --item parameter, but of course that needs the id of the item and even then it did not seem to work on individual TV episodes.

For example this will refresh one of my movies:
/usr/lib/plexmediaserver/Plex\ Media\ Scanner --refresh --force --item 451454
returns this:
GUI: Requesting metadata for 'Cleaner'

But If I try that with a single TV Episode Nothing is returned in the console

and found this:

Which kind of suggests the --file parameter does not actually work!

Ok, that probably explains why I still have not had any luck either :slight_smile:

Thank you, blim5001!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.