[Suggestion] Cache Video/Picture Thumbnails

If you have a suggestion for a feature, post it here
Zero3K
Posts: 16
Joined: Mon Jun 03, 2013 7:52 am

[Suggestion] Cache Video/Picture Thumbnails

Post by Zero3K »

It would be nice if there was an option to cache the thumbnails of videos/pictures in order to speed up browsing.
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Cache Video/Picture Thumbnails

Post by SharkHunter »

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.
User avatar
SubJunk
Lead Developer
Posts: 3705
Joined: Sun May 27, 2012 4:12 pm

Re: Cache Video/Picture Thumbnails

Post by SubJunk »

I have been thinking about adding this feature for a while now, I agree. It's on my wishlist
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Cache Video/Picture Thumbnails

Post by SharkHunter »

It looks like thumbs are cached

Code: Select all

if (getMedia().getThumb() != null && configuration.getUseCache() && inputFile.getFile() != null) {
PMS.get().getDatabase().updateThumbnail(inputFile.getFile().getAbsolutePath(), inputFile.getFile().lastModified(), getType(), getMedia());
}
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)
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
User avatar
SubJunk
Lead Developer
Posts: 3705
Joined: Sun May 27, 2012 4:12 pm

Re: Cache Video/Picture Thumbnails

Post by SubJunk »

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.
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Cache Video/Picture Thumbnails

Post by SharkHunter »

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.
User avatar
SubJunk
Lead Developer
Posts: 3705
Joined: Sun May 27, 2012 4:12 pm

Re: Cache Video/Picture Thumbnails

Post by SubJunk »

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.
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Cache Video/Picture Thumbnails

Post by SharkHunter »

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

Code: Select all

ByteArrayOutputStream out = new ByteArrayOutputStream();
								ImageIO.write(image, "jpeg", out);
								setThumb(out.toByteArray());
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.
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
User avatar
SubJunk
Lead Developer
Posts: 3705
Joined: Sun May 27, 2012 4:12 pm

Re: Cache Video/Picture Thumbnails

Post by SubJunk »

Yep I think you're right that's the way to do it
User avatar
SharkHunter
Developer
Posts: 648
Joined: Fri Jun 01, 2012 9:36 pm

Re: Cache Video/Picture Thumbnails

Post by SharkHunter »

With the risk of spamming the forum with boring details. Here we go:
The thumbs are cached in memory (the full binary data)

Code: Select all

setThumb(out.toByteArray());
. 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??
We reject: kings, presidents and voting.
We believe in: rough consensus and running code.
Post Reply