[Suggestion] Cache Video/Picture Thumbnails
[Suggestion] Cache Video/Picture Thumbnails
It would be nice if there was an option to cache the thumbnails of videos/pictures in order to speed up browsing.
- SharkHunter
- Developer
- Posts: 648
- Joined: Fri Jun 01, 2012 9:36 pm
Re: Cache Video/Picture Thumbnails
To some extent they are cached. For example all thumbs that are fetched from an url are normally saved on disc to speed up look up...
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
We believe in: rough consensus and running code.
Re: Cache Video/Picture Thumbnails
I have been thinking about adding this feature for a while now, I agree. It's on my wishlist
- SharkHunter
- Developer
- Posts: 648
- Joined: Fri Jun 01, 2012 9:36 pm
Re: Cache Video/Picture Thumbnails
It looks like thumbs are cached
But maybe that code dosn't work?
usecache has to be true but other than that?
Take a look at protected void checkThumbnail(InputFile inputFile)
Code: Select all
if (getMedia().getThumb() != null && configuration.getUseCache() && inputFile.getFile() != null) {
PMS.get().getDatabase().updateThumbnail(inputFile.getFile().getAbsolutePath(), inputFile.getFile().lastModified(), getType(), getMedia());
}
usecache has to be true but other than that?
Take a look at protected void checkThumbnail(InputFile inputFile)
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
We believe in: rough consensus and running code.
Re: Cache Video/Picture Thumbnails
That's only if the file cache is enabled. The feature I want to add would cache the thumbnails even without the cache enabled. I think the ability to run without a file cache is one of the big things that makes us better than other programs and we can make that even faster by caching the thumbnails.
- SharkHunter
- Developer
- Posts: 648
- Joined: Fri Jun 01, 2012 9:36 pm
Re: Cache Video/Picture Thumbnails
Agree the non-file cache is a big +. I'm just wondering how this will affect the memory useage?
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
We believe in: rough consensus and running code.
Re: Cache Video/Picture Thumbnails
Well we already kindof do it with the way we allow users to have their own cover images, so we check for an image with the same name as the video. I guess all we need to do is to make UMS save the thumbnails it generates instead of storing them in memory (is that what we do now? I have no idea), and make a nice folder for them (programdata\UMS\thumbnails)
Each thumbnail is only about 320x180 and jpeg if memory serves, so even with thousands it shouldn't take up much space.
Each thumbnail is only about 320x180 and jpeg if memory serves, so even with thousands it shouldn't take up much space.
- SharkHunter
- Developer
- Posts: 648
- Joined: Fri Jun 01, 2012 9:36 pm
Re: Cache Video/Picture Thumbnails
Yep your correct. All the code is there but not used (in some obscure way).
Take a look at https://github.com/UniversalMediaServer ... aInfo.java
At the bottom (of parse) we do
So (if I'm right thats one messy function) we should swap out to a file and then do some check to see if the file already exists and return early.
Take a look at https://github.com/UniversalMediaServer ... aInfo.java
At the bottom (of parse) we do
Code: Select all
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(image, "jpeg", out);
setThumb(out.toByteArray());
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
We believe in: rough consensus and running code.
Re: Cache Video/Picture Thumbnails
Yep I think you're right that's the way to do it
- SharkHunter
- Developer
- Posts: 648
- Joined: Fri Jun 01, 2012 9:36 pm
Re: Cache Video/Picture Thumbnails
With the risk of spamming the forum with boring details. Here we go:
The thumbs are cached in memory (the full binary data). So the real question here is what is most efficient to extract the thumbs and store the data in memory or to extract it to a file and read from the file when needed? Of course you could extract to the file and then re-read the file back into memory.
In theory it should be most efficient to extract them once and read from file but I'm wondering if it is really that much more??
The thumbs are cached in memory (the full binary data)
Code: Select all
setThumb(out.toByteArray());
In theory it should be most efficient to extract them once and read from file but I'm wondering if it is really that much more??
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
We believe in: rough consensus and running code.