c# for all the really advanced video searches

Extending the video search

The basic idea I show you here is how to write a script in C# that determines if a video matches your search criteria or not and put the matching videos in a custom Bin.

You will learn by a simple step by step example how to write a script that goes through all videos in you catalog and puts all short videos(the critera we have as an example) in a bin.

After you have this skill you can expand your skill and continue to experiment.

About the native video search

Fast video cataloger has a very powerful, fast and simple search engine. The text below show how easy you can extend it even more with advanced custom video search in C#.

Our simple user interface make searching in Fast video cataloger straight forward for everyone. However, we do not provide a SQL interface for search so there are searches you can simply not express given our user interface. With the scripting interface you can do basically anything.

AI For example… What if you want to search with facial recognition or object detection or the next big thing in AI and video?

You an do all this and more by leveraging the scripting capabilities in Fast video cataloger

step by step breakdown on the Video search script in c#

Run(…) in the code below, is the entry function where the execution of the script starts.

    static public void Run(IScripting scripting, string argument)
    {
        FilterToBin instance = new FilterToBin(scripting);
        instance.SetBinTarget("short videos");
        instance.Filter();
        scripting.GetGUI().Refresh("");
    }

I have encapsulated all functionality in a class called “FilterToBin” that has two functions.

SetBinTarget() let you set the name of the Bin that will be used for search results. Please note that this Bin will be cleared every time you run the search.

Filter() does the actual filtering of videos.

    private void Filter()
    {
        var catalog = m_Scripting.GetVideoCatalogService();

        VideoQuery query = new VideoQuery();
        VideoFileEntry[] videos = catalog.SearchVideos(query);

        long bin_id = CreateBin();

        foreach (VideoFileEntry entry in videos)
        {
            if (IsVideoPassingFilter(entry))
                catalog.AddVideoToBin(entry.ID, bin_id);
        }
    }

The Filter() function first does a search to get all videos. In this example we pass in en empty VideoQuery object. That will give us all videos in the catalog. You can of course leverage the search here and first do a high level search to get a subset of your videos and then apply a more advanced search on that subset.

We then call CreateBin() to ensure we have a bin to put our results in. If we look closer in the FilterToBin class the CreateBin member function has some logic to create a Bin if its not already created and clear it from videos if it already exists.

Finally we iterate over all videos and call the IsVideoPassingFilter() function on each video. Videos that pass the test are put in the result Bin.

    private bool IsVideoPassingFilter( VideoFileEntry entry )
    {
        if ( entry.LengthSeconds < 60)
            return true;
        return false;
    }

If you want to change the filter criteria this is the only function you need to edit. In this example we only check if the video length property is smaller than 60s.

To run this script you copy paste it or type it (or load it) into the script window and then click the Run button.

Go the Bin window and select the "short videos" to see the result (if the bin is not there go into the edit bin to refresh the window, this is needed on older versions of Fast video cataloger).

Edit button in bin window

Edit button in bin window

Full source code in C#

using VideoCataloger;
using VideoCataloger.RemoteCatalogService;

public class FilterToBin
{
    IScripting m_Scripting;
    string m_BinLabel;

    FilterToBin(IScripting scripting)
    {
        m_Scripting = scripting;
    }

    private void SetBinTarget(string bin_label)
    {
        m_BinLabel = bin_label;
    }

    private void Filter()
    {
        var catalog = m_Scripting.GetVideoCatalogService();

        VideoQuery query = new VideoQuery();
        VideoFileEntry[] videos = catalog.SearchVideos(query);

        long bin_id = CreateBin();

        foreach (VideoFileEntry entry in videos)
        {
            if (IsVideoPassingFilter(entry))
                catalog.AddVideoToBin(entry.ID, bin_id);
        }
    }

    private bool IsVideoPassingFilter( VideoFileEntry entry )
    {
        if ( entry.LengthSeconds < 60)
            return true;
        return false;
    }

    private long CreateBin()
    {
        var catalog = m_Scripting.GetVideoCatalogService();
        Bin[] all_bins = catalog.GetAllBins();
        foreach (Bin bin in all_bins)
        {
            if (bin.Label == m_BinLabel)
            {
                VideoFileEntry[] videos = catalog.GetVideosInBin(bin.BinID);
                foreach (VideoFileEntry entry in videos)
                {
                    catalog.RemoveVideoFromBin( bin.BinID, entry.ID );
                }

                return bin.BinID;
            }
        }

        Bin target_bin = catalog.CreateBin(m_BinLabel, -1, 0xffffff);
        return target_bin.BinID;
    }

    static public void Run(IScripting scripting, string argument)
    {
        FilterToBin instance = new FilterToBin(scripting);
        instance.SetBinTarget("short videos");
        instance.Filter();
        scripting.GetGUI().Refresh("");
    }
}

Video search layouts improved

Video search layouts and video companion images gets improvements

A new version of fast video cataloger is available today to download from videocataloger.com/download.

Fast video cataloger is the program that makes it easy for any small busniess to regain control and leverage their video content. Find what you are looking for faster and improve your video workflows.

In Version 4.42 we included the state of the search boxes in the layout. You can now setup exactly how you want them for each layout (Do not forget to save the layout once you have it configured). We have learned that there is two fundamental different ways of using the program. Some almost always use the scene search while other users mainly focus on the video search. Hopefully this new improvements to video layouts will make it even easier to customize the program to your prefered workflow.

Some customers have reported that the companion image function does not work as expected. We think we can trace this to corrupt meta data in jpeg files. In 4.42 we have better error handling to ignore this bad data and still load the image. Hopefully, this will sort your issues if you this you have had issues loading images in the
previous versions. If you are still having issues please contact support so we can get it sorted.

This update is free for all customers and if you have not tried to program yet you can get downlaod a free trial version from here.

Improved video keyword search

Today we released Fast Video Cataloger 3.95, and as always the update is free for current customers.

New video indexing engine

This new version contains a new video indexing engine. The new engine uses a more direct approach to configuring the filters that should be able to index more videos even if DirectShow filters on the computer are misconfigured. This new way of indexing videos is now the default. If you have issues indexing a video with the new version, you can switch back to the old engine from the “Video Indexer” tab in the Preferences, check the “Use windows filters” checkbox. You might also want to switch back if you have rare or custom codecs.

And here’s a tip: if a video fails to index, you can switch index method and retry the failed videos. Some might work with the alternative method.

The integrated video player still uses the default Windows filters so it is possible that videos can be indexed but not played back correctly if filters are misconfigured on the computer.

I might write a more detailed post about how the new engine works later. Anyway, the net result of the update is that most people should have less codec issues and an easier time indexing videos.

Updated components

Now and then, Microsoft release a new compiler, like they did several times in the past. A new compiler means, in theory, faster and better running code and fixed bug in the base libraries. For this version, I took the time to recompile all components of the program with the latest visual studio and the latest c-runtime. In theory this should be an improvement, but in practice you might not notice any difference.

New video keyword search

Keyword search now support “ALL” and “ANY” searches. In the “Advanced filter dialog” on the keyword tab you will now find a “match” radio button. We have wanted to update the whole search interface for a while but instead of waiting to do a whole rewrite I decided to get this important improvement in as soon as possible.

Download the latest version from the download page

How to instantly find your best video moments

Today I want to show you how to find those special video moments instantly using Fast Video Cataloger!

But, first some background…

By annotating your catalog with keyword tags, or as it is called in the Fast video cataloger program, keywording, you make the search process more powerful. Remember the search, browse and find method ( https://videocataloger.com/how-to-search-browse-and-quickly-find-a-video-clip-in-your-video-file-collection/ )?

Setting keyword tags to a video or to a specific time in the video

Search results on scenes

 

In Fast video cataloger you can set keyword tags to a video or to a specific time in the video, which we call a Scene. When you set keywords to a video none of the individual scenes in that video is tagged, more on that later.

Remember to set default keywords to videos when you add them to your catalog. You can always apply keywords to already added videos but the habit of setting default keywords when videos are added is a big time saver.

Keywording videos

Keywording in Fast video cataloger is carried out from the keywording tab.

Set the radio button to “Tag Video” when a Keyword applies to one or more videos, for example videos from a safari or from a whole season of a serie. Then select the files you want to tag from the Video Catalog window. You select multiple videos in this list by holding down Shift or Ctrl while selecting. All videos selected, marked with green, will get the keyword you enter in the keywording tab.
The keywords you have used before will appear in the suggestion list

Keywords you have used before will appear in the suggestion list, you can click on the words in this list instead of typing them in.

Click the filter button to open the advanced filter dialog window and then the Filter on Keywords tab. When you filter on keywords, the video catalog window display the videos that are tagged with at least one of your selected keywords.

Keywording video scenes 

To set a keyword to a specific scene in a video, click the radio button “Tag selected scenes”. Click the scene thumbnail(s) you want to keyword. Multi select scenes by holding down Ctrl or Shift when you click on scene thumbnails. If you just want to select a scene thumbnail hold down the Ctrl key and the video will not start playing, which otherwise is the standard behavior for clicks on video scenes. Next, type or select your keyword for the scene and press Enter.

Video scene thumbnails with keywords are rendered in a different tint on the thumbnail text overlay. When you hover your mouse pointer above the overlay you see the keywords for that scene.

The “scene search” tab lets you search for scenes in a very smooth manner. Type the keyword and press enter to search for the scenes or simply choose from the suggestions.

Scene search is one of the features in Fast video cataloger I like the most!

You will get the result of the scene search in the “scene search” window. Your result may contain scenes from any number of videos. You can play any of the different videos from the scene time by clicking on the video scene thumbnail. Scene search is really great for finding those special moments!

To open the whole video with the scene you right click a thumbnail and select “go to video”.