FAQ  •  Register  •  Login

Thumbnail generation from multiple frames

<<

josch.hh

Serviio lover

Posts: 65

Joined: Sun Dec 20, 2015 10:01 pm

Post Mon Dec 28, 2015 10:11 pm

Thumbnail generation from multiple frames

A nice to have feature request:

Concerning thumbnail creation by grabbing a single frame at some time stamp within a movie it often represents the corresponding movie better to extract several frames at different location in time within the movie timeline and combine them.
I attached an example.


It is really easy to do in java:
(this piece of code is using javacv, so forget the grabbing part... for the example only the combining part is interesting and simple... and dont forget the aspect ratio in case..)

  Code:
      
         // Set resolution
         int imageHeight = frameGrabber.getImageHeight();
         int sizedWidth = (int)(frameGrabber.getImageWidth()*frameGrabber.getAspectRatio());
         
         // Setup combined image
         BufferedImage combinedImage = new BufferedImage(sizedWidth*2, imageHeight*2, BufferedImage.TYPE_INT_RGB);
         Graphics g = combinedImage.getGraphics();
         
         for (int i = 1; i <= 4; i++) {
            
            int seekFrame = seekFrameGap*i;
            
            // Jump to frame
            frameGrabber.setFrameNumber(seekFrame);
            
            frameGrabber.setDeinterlace(true);
            
            // Grab image
            Frame frame = frameGrabber.grabImage();
            
            // Convert grabed frame to Java image
            BufferedImage img = frameConverter.convert(frame);
            
            // Size the Image with aspect ratio
            BufferedImage sizedImg = toBufferedImage(img.getScaledInstance(sizedWidth, imageHeight, Image.SCALE_SMOOTH), img.getType());   

            // Combine the 4 thumbnails
            int x = (i == 1 || i == 3) ? 0 : sizedWidth;
            int y = (i == 1 || i == 2) ? 0 : imageHeight;
            g.drawImage(sizedImg,x,y,null);
            

         }

         ImageIO.write(combinedImage, THUMBNAIL_FORMAT, extractedThumbnail);
Attachments
2014-07-15 00.50.jpg
2014-07-15 00.50.jpg (79.76 KiB) Viewed 2878 times
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Dec 28, 2015 10:48 pm

Re: Thumbnail generation from multiple frames

the default DLNA thumbnails are only 160x160, so I think splitting it into 4 would make them virtually impossible to distinguish

Return to Feature requests

Who is online

Users browsing this forum: No registered users and 12 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.