Video Preloader (avoids HDD spinup latency when starting a Movie or Episode through Plex, Jellyfin or Emby)


Recommended Posts

48 minutes ago, kizer said:

Is there a code change that you could recommend that says to skip those or ignore them?

This should be possible.

 

Maybe I could also add an option which allows sorting by the year which is inside the parent folder name like "2004" in "/Lost (2004)/S01E01.mkv". But by that recently added content which has an old airing date, won't be cached.

Link to comment
3 minutes ago, mgutt said:

This should be possible.

 

Maybe I could also add an option which allows sorting by the year which is inside the parent folder name like "2004" in "/Lost (2004)/S01E01.mkv". But by that recently added content which has an old airing date, won't be cached.


I have found a Bulk renamer and have begun changing the messed up files from 2038 to 2018. Not sure what happened, but I think I have a plan of attack. Thank you for the offer/idea. It’s only a 100-200 or so files and I’m 1/4 of the way done. 

Link to comment
49 minutes ago, kizer said:

Bulk renamer

This should not help. The script sorts by file modification time and not the year in the filename (that was the idea I mentioned in my last post) ;)

 

All files, renamed by this bulk renamer tool, will probably receive a newer file modification time and so pushed to the top of the preloading list.

Edited by mgutt
Link to comment

I checked the file listing and it shows the Modified date as 2018 vs 2038. I’m basically changing the attributes not the actual file name. 
 

I’ll do my thing and report back. Or actually I’ll test it again and see if the priority has shifted first before doing more. 

 

update********

 

Every file I’ve changed the modified date is not being scanned. So it’s doing exactly what I hoped it would accomplish.  Just have to do some house cleaning on my end. 
 

Thanks so much for this script. I can verify it does work on 6.9 RC-30. 

Link to comment
6 minutes ago, LSL1337 said:

but if I don't want to map these to RAM (don't have a huge amount)

At the moment you can't map it to something else. But note: Preloading does not reserve RAM. It stays free. But with a small amount of RAM the preloaded data will be overwritten by other processes really fast, so the use of preloading will be really low on your setup.

Link to comment

Thanks this script, I always do same thing, but fetch whole moive to RAM during watching.

 

Sound good have additional features, when a file open time long enough i.e. 5min, ( or simple as file scan still in open state if compare to previous file scan ) then fetch those files to RAM automatically.

Edited by Vr2Io
Link to comment
  • 2 weeks later...

Hello,

 

Fantastic script, works great!

 

One question, is there a more reliable way to determine if the content is coming from the RAM or Disk? I ask because it seems on my machine even from RAM is taking ~ 0.170s which from looking at your script it means this gets counted as from Disk.

 

I am also working on a solution to catch what is On Deck, I will share once I have it working.

 

Thanks,

Chris

Link to comment
1 hour ago, christoefar said:

I am also working on a solution to catch what is On Deck, I will share once I have it working.

 

Thanks,

Chris


That would be neat to have too. Any consideration if you have multiple users on your Plex Server unless Plex just sees all on deck files?

Link to comment
1 hour ago, chris.child said:

Hello,

 

Same Chris as before - just a new email address.

 

I have it working in a crude way, it does only work for me currently. I will have a look at the Plex API and see if it is possible to pull back the On Deck for all users. Selfishly, my main concern is me though!

 

@mgutt is the code on GitHub by any chance?

 

Chris

 

The code for this project is in the first few posts to this thread. 

 

I wouldn't mind just me because I'm selfish too Lol. However if would could cover all users it would round out the code very nicely.

Link to comment

The script works great.  I like the On Deck idea.  Another feature request would be the ability to pick certain episodes or movies to always be preloaded into Ram.  For example, my kids tend to watch the same episodes and movies over and over.  But because they have been on my Plex server for so long, they are not preloaded.  Thanks and keep up the good work!

 

Brad

  • Like 1
Link to comment
  • 2 months later...
  • 8 months later...

Trying to figure out how this script works. How does plex know to load the initial data from RAM, and the rest of it from the disk?

 

Would like to adapt the script to use an SSD instead of RAM for the first bit of data (since that could just be persistent, and has A LOT more space to store all of it).

 

edit: looking more at the script, it looks like the head and tail commands are used for printing the beginning and end of the file to /dev/null. So I guess that by doing so, the system automatically caches that bit of the file?

Edited by xorinzor
Link to comment
28 minutes ago, xorinzor said:

So I guess that by doing so, the system automatically caches that bit of the file?

Yes. This is the default behaviour of Linux. Everything which is read from a disk is written to the RAM. So this is only a trick to prefill the RAM. And because of that it's impossible to use the SSD. I tried to use a swap file, but it's sadly not possible to read data directly into the swap file.

  • Thanks 1
Link to comment
  • 3 weeks later...

Would it somehow be possible to do reserve ram for this?

I have 64GB of RAM in my server and it'd be nice to allocate a few GB for this. But I'd also like to guarantee that no other processes use the RAM (there's way more then enough, so I can spare to allocate a bunch).

 

EDIT: nvm, forgot about the head_size being 60MB (or even more).

Edited by xorinzor
Link to comment
  • 2 months later...

Is there still support for this script? Coming across an error message -

tr: write error: Broken pipe
tr: write error
cut: write error: Broken pipe

I have 128GB of RAM installed, and set free ram usage to 75% so I should be able to utilize about 96GB, my dashboard only shows about 9% utilized overall, i'm assuming this error is preventing the script from fully running.

Link to comment
  • mgutt changed the title to Video Preloader (avoids HDD spinup latency when starting a Movie or Episode through Plex, Jellyfin or Emby)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.