Page 1 of 1

Thumbnail generation from multiple frames

PostPosted: Mon Dec 28, 2015 10:11 pm
by josch.hh
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);

Re: Thumbnail generation from multiple frames

PostPosted: Mon Dec 28, 2015 10:48 pm
by zip
the default DLNA thumbnails are only 160x160, so I think splitting it into 4 would make them virtually impossible to distinguish