Saving thumbnails

Sometimes you need a video thumbnail for use outside of Fast video cataloger. You can easily just right click the thumbnail and select “save as”. This is fast and easy if its a single thumbnail you want to save but it will be very time consuming if you want to save all thubmnails for a video, or for several videos.

This is a good example of where the scripting support in Fast video cataloger can help, and it is really easy.

Exporting thumbnails from C# script

This example shows how to export out all thumbnails for the currently selected videos as files.

For each video we create a foder called thumbnails in the same folder as the video file. Then we get all the thumbnails for the selected video by calling GetThumbnailsForVideo(video_id, true );
we get all the thumbnails and only need to go through them all, generate a filename and call System.IO.File.WriteAllBytes(filename, image_data);
to write out the image to file.

using System;
using System.IO;
using System.Collections.Generic;
using VideoCataloger;
using VideoCataloger.RemoteCatalogService;

class ExportThumbnails
    static public void Run(IScripting scripting, string arguments)

        var service = scripting.GetVideoCatalogService();
        ISelection selection = scripting.GetSelection();
        List selected = selection.GetSelectedVideos();
        foreach (long video_id in selected)
            var video_file_entry = service.GetVideoFileEntry(video_id);
            string target_folder = video_file_entry.FilePath; 
            int path_end = target_folder.LastIndexOf('\\');
            target_folder = target_folder.Substring(0, path_end+1);
            target_folder += "Thumbnails\\";
                DirectoryInfo info = Directory.CreateDirectory(target_folder);
            catch (Exception ex)
                scripting.GetConsole().WriteLine( ex.Message );

            long image_no = 1;
            Dictionary thumbnails = service.GetThumbnailsForVideo(video_id, true );
            foreach (KeyValuePair thumbnail_entry in thumbnails )
                byte[] image_data = thumbnail_entry.Value.Image;

                string filename = target_folder + image_no.ToString() + ".jpg";
                scripting.GetConsole().WriteLine("Saving image to : " + filename);
                System.IO.File.WriteAllBytes(filename, image_data);