Fast Video Cataloger 6.31 – Play videos from a web server

I am happy to let you know we have just made Fast video cataloger 6.31 available

Play videos from a web server

We have added new support to let you set up videos to be served from a web server. Access this from the catalog/info screen and the “Use Hosted Videos” button. This enables you to put your videos on a web server and then share a catalog with other people so they can easily access your video files. You can then share the relatively small catalog file where they have quick instant access to search and browse without having to distribute all the large video files with them. And you can use this for a selected number of videos in a catalog, i.e. a catalog can have a combination of videos hosted on a server and loaded from your local filesystem.

play video through web server.

Please note that not all videos can be served from a web server, we recommend modern containers like mp4 for videos hosted this way. It is also always slower to load over a server so if you do not need this functionality you should not use it. Also, note that indexing currently needs to happen through the Windows file system.

Save to other than the selected layouts

You can now save a windows layout to another layout than the currently selected one. This new functionality is available from the view menu. Select the layout you want to save to from the dropdown list and then click Save. By default, the dropdown will be the current layout.

Chrome browser

The browser for the start page has been switched to a Chromium-based browser from internet explorer. We have also extended the scripting interface with a new function to give you direct access to the browser window. This will allow an easy way to either write out results to a web page integrated into the software or to gather data from a web page into your solution.

Scripting improvements

The execution of scripts can now be asynchronous. This will allow you to have scripts running as you interact with the rest of the user interface.

The load script dialog will now default to open in the sample script folder, and then the last opened folder.

A new sample script get_actors.xaml.cs will show you how to integrate Fast video cataloger with an external web service. This script is explained in detail here

Progressbar

The program icon in the taskbar now shows progress when a video is being indexed. The progress is per videos not for all videos in the current batch.

And other minor fixes…

It is now possible to multiselect images in the companion image gallery and remove them from the catalog. The Update dialog has gotten an improved layout.

Using TMDB Web API ( The Movie DataBase )

TMDB (The Movie DataBase ) is a large open internet database you can use to search for movies, tv shows, and people in movies. It also has a web API.

Fast video cataloger is a software to organize video clips so you can quickly search, browse, and find what you are looking for.

This example will show how to use the scripting support in Fast video cataloger to integrate with the web API in TMDB. My goal is to show you have to integrate a search for actors using the TMDB web API and then add the metadata to Fast video cataloger. With this start, I hope you can expend it to what you need and perhaps use other functions in the TMDB API.

Script demo

Getting started

If you do not already have Fast video cataloger installed you can download a free trial from here

Before we can start you also need to create a free account at TMDB that you can get from here, When you have your account to go your profile, click settings and find the API tab and request a developer API key.

The script we show here can be downloaded from our sample git hub repository

Place the downloaded scripts get_actor.xaml and get_actor.xaml.cs in the script folder of your fast video cataloger installation.

Open the get_actor.xaml.cs and fine the line near the top that reads

static string api_key = "";

and replace the empty api_key string with your TMDB API key.

Running the script

To run the script in Fast video cataloger open the Script console window. In the window click on the Load button and load the get_actor.xaml.cs script. Click run and you should see a window like this:

tmdb actor search

Integrating with tmdb people search

Search for an actor and you should see something like this

tmdb search results

results of a search in the movie database

You can then click “Add to catalog” to add the actor to your Fast video cataloger database

Script overview

The C# script that is running uses WPF for the user interface. The user interface is defined in the XAML file. We use the rest API for TMDB. You can find full documentation for it here

Note that this sample just uses a minimal subset of the TMDB API. But, the principles are the same for the whole API, and it should be pretty easy to extend this with more functionality. For example, getting poster images or searching for movies.

Another difference to most other Fast video cataloger samples is that this one uses async programming which is needed for the web APIs.

Script walkthrough

You can find the full xaml file here and the full source file here

References

At the very top of the script we need to add our external references. This is what normally would go into “references” in a visual studio c# project. In a Fast video cataloger script you use a comment in the format of :”//css_ref [dependency]”.

//css_ref WindowsBase;
//css_ref PresentationCore;
//css_ref PresentationFramework;
//css_ref System.Runtime;
//css_ref System.ObjectModel;

WindowsBase, PresentationCore, and PresentationFramework are needed for the WPF user interface. System.Runtime and System.ObjectModel has the c# code we need to access and parse the web API.

Static variables

At the top of the script, we have a few static variables. The important one here is again the api_key variable, here you need to fill in your key as mentioned earlier.

Entry point

Run is the entry point of all scripts running from Fast Video cataloger:

static public async Task Run(IScripting scripting, string argument)

The only thing we do in the entry function is to save the passed in scripting interface and then create the GetActors WPF window and show it. We intentionally call Show() and not ShowDialog() since we want to be able to bring up the actor window in Fast video cataloger when we have this window open.

Constructor

In this example, we have put all code in the HelloWindow class. This has the same structure as the basic HelloWpf.cs sample.
The constructor loads the XAML interface definition and sets up the window. It also establishes the connection between the buttons and their click functions (unfortunately we do not support binding directly in the XAML as the XAML file is loaded through the script engine ).

Searching

When the search button is clicked we will get a callback to Search_Click(…). This is the main function that performs the search. We first fetch the text the user entered in the search box.

Then we call SearchActors asynchronously and expect to get a CPersonSearchResult back, more on that later.

private async Task SearchActors( string query )
{
  string encoded_query = System.Net.WebUtility.UrlEncode( query );
  string search_line = api_base_url + "search/person?api_key=" + api_key + /
         "&language=en-US&query=" + encoded_query + "&include_adult=true&page=1";
  CPersonSearchResult header_result = await GetFromJSON(search_line);
  return header_result;
}

After that, we have to check if we got a search hit. In this example, we only care about the first result but you can of course list all the results and let the user pick one of them.

We have our first actor and pick the name. We then call MakeProfileImageUrl(…) to generate a URL for the profile image. We call GetImageData(…) to get the image from that URL.

At this point, we have most of the data we need.

We create a new Actor class in the Fast video cataloger format and store that in m_CurrentActor. We fill in the data members with data from the search and the downloaded portrait data.

Next, we call GetPerson() with the TMDB id for the first actor. Once we have done that we have all the data we need from TMDB.
We create a WPF image from the downloaded image data and call SetActorToUI() to update the user interface.

SetActorToUI()

This function simply updates the user interface from the variable we have designed. The portrait is set to the image, the name and the description is set. The XAML file defines the whole layout of the user interface including size and positions of elements and fonts.

Adding to Fast Video cataloger catalog

If you click add to catalog after you have searched and found an actor you will get a callback to AddToCatalog_Click(…). Here we simply get the interface to the video catalog and call AddActorToDB() with the m_CurrentActor we filled in earlier when we got the search result.

GetConfiguration()

GetConfiguration() is a wrapper to load the TMDB configuration. You only need to call this once in your application and it is needed to among other things figure out the path to any image resource. The configuration is stored globally in m_Configuration. This is a very short function and it is a good example of how to use the TMDB rest API.

First, we create the URL that we will use to access TMDB. It always starts with the base URL and then the API we want to use and some arguments. Among the arguments, you always pass in your API key. We then use this URL and call one a utility function, GetFromJSON(), we have in the sample code. This function takes a class argument, which is of type of the JSON file we want to get from the URL. And, it returns an object of that class or null if it fails.
Let us take a closer look at that utility function.

GetFromJSON()

GetFromJSON() is an asynchronous function that you pass the class of what you want to read from the query string. There is some initial setup and then we call GetAsync( query ) that will asynchronously call the URL and get the result. Once we have the result we read the data from the response message as a string. We then create a memory stream to the string data and create a DataContractJsonSerializer object to parse our data from the JSON data and create the C# object.

public async Task GetFromJSON(string query)
{
  T parsed_stuct = default(T);
  var handler = new HttpClientHandler();
  handler.AllowAutoRedirect = false;
  var client = new HttpClient(handler);
  try
  {
    var videoGetIndexRequestResult = await client.GetAsync(query);
    var result = videoGetIndexRequestResult.Content.ReadAsStringAsync().Result;
    var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(result));
    var serializer = new DataContractJsonSerializer(typeof(T));
    parsed_stuct = (T)serializer.ReadObject(ms);
    ms.Close();
  }
  catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }
  return parsed_stuct;
}

If you want to use other parts of the TMDB API you need to create classes for the data that are returned by the functions.

SearchActors( string query )

The SearchActors() function is very similar to the GetConfiguration() function but it uses the search/person API. We pass the api_key but also some extra arguments.

One of the arguments is a query string, this needs to be URL encoded to handle special characters like spaces.

Then again, once we have our URL, we simply use the GetFromJSON() utility to read the result into the CPersonSearchResult class. This class includes info about how many results you have from your query and some basic information about each result returned in an array of class CActorResult. Here you have the name of the actor, an id that we can use in other API calls and a profile_path. Profile_path is needed when you want to create an URL to fetch the profile picture.

MakeProfileImageUrl()

MakeProfileImageUrl() is a utility function that is used to generate an URL to a profile image. For this, we need the configuration data where you have the base_url for all profile images. We need to decide on the size of the image, the different types of sizes are also listed in the profile image, and then finally we need the part of the URL that is unique for every actor. Once we have this URL we can just get the data.

GetImageData()

GetImageData() takes the URL from MakeProfileImageUrl() or really any image URL in the TMDB image URL format. We again use the WebClient API and call DownloadDataTaskAsync(). This function will asynchronously download the image data to an array. This is the right format we need to pass to Fast video cataloger. But we need one more step to display it in the WPF user interface.

private async Task GetImageData(string url)
{
  byte[] image_data = null;
  try
  {
    Uri image_url = new Uri(url);
    var webClient = new System.Net.WebClient();
    image_data = await webClient.DownloadDataTaskAsync(image_url);
  }
  catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }
  return image_data;
}

LoadImageFromStream()

LoadImageFromStream() takes a memory stream to the bytes we loaded with GetImageData() and create a BitmapImage object from it. This object can then later be assigned as a source to any Image element we have in our XAML user interface.

Conclusion

I have shown how you can expand on the functionality of Fast video cataloger with web API. In this example we used TMDB but there are tons of other web APIs that might be useful and my hope is that this sample will make it easier for you to get started.

Fast Video Cataloger 6.30 supports video metadata

Fast video cataloger 6.30 is now available with new support for video metadata. Download from our download page

metadata written to video files

We now support writing New option to save out metadata inside the video file. This option will save basic metadata like keywords, descriptions, and ratings into the metadata section of the file. This will make it available in Windows properties of the file. This also means that it will be available for Windows search. Please note that this type of metadata is not supported by some of the older video containers but it should be supported by modern formats like mp4. This option is disabled by default but can be enabled from preferences on the metadata tab.

.nfo metadata next to video files

We have added a new requested feature to write out .nfo file next to the video file. The nfo file will contain basic metadata like keywords, description and ratings in the Kodi format. This option is only recommended if you want to share the metadata in the catalog with another media manager. It is disabled by default and can be enabled from preferences. If the video file already has a .nfo file it will be updated with the data from Fast video cataloger.

video metadata preferences

video metadata settings

More shortcuts

It is now possible to assign shortcuts to show and hide Windows. No default shortcuts are set for these, but you can assign them if you have a need. We still recommend using layouts in most cases.

Bug fixes

And we have continued to fix reported bugs. Import videos can now handle special folders correctly and can detect if a video has been imported already. I.e. if you import videos already in the target catalog they will be skipped. If you had the playlist window undocked and floating and then tried to change the order of playlist items the program crashed, this is now fixed.

Fast Video Cataloger 6.29

Today we release Fast video cataloger 6.29.

A quick update this time around, so a bit fewer changes than usual but I think they are pretty important.

Companion images

It is now possible to delete multiple selected images in the companion image browser window.

If adding or removing images to the companion image browser the window was not refreshed until another video was selected.

Usability

Improved tooltips for the views.

Fast Video Cataloger 6.28

Today we release Fast video cataloger 6.28.

So what is new in this version?

Ctrl+I

The interactive search, Ctrl+I, now selects the search text when you show it after hiding. Just start typing to get a new search or move with arrows to edit the previous search text. If you have not used the interactive search do give it a try.

More Companion image optimizations

We have continued to optimize the companion image browser. This time we did optimizations for when the companion image windows are not visible in a layout. This should make loading of video thumbnails images in cases a video had a very long list of companion images. We have also optimized the companion image browser itself even more.

Crash fix

Fixed a crash when dragging an actor from a floating (non-docked) window into the cast window.

Check for update

Added a new check for update button, and we do a check for updates in the background now when the program starts.

Fast Video Cataloger 6.27

I am happy to let you know we have just released Fast video cataloger 6.27.

So what is new in this version?

Companion image browser

Companion image browser lets you view photos in the same folder or a subfolder of the video. We have done a very significant performance pass on the companion image browser. And, we have added an image cache to make it even faster.

Actions

There is now a way to launch actions without waiting for them to complete and without showing the console window. The recommendation is to first test your command with the usual command-line version so you can view what is being executed. Once it is working you can switch to the new mode, “Shell execute”

Execute commands

We have added a new action argument to pass in the selected companion image, {preview_image} we also added the folder of a video “{video_folder}”.

Preview video companion image

Problem opening catalog

We have added check and error dialog for when the program is not allowed to write to a folder. This can be caused by some antivirus/antimalware software if they are not configured correctly. Now there is a message instead of a silent fail when you tried to create a new catalog in a folder the program was not allowed to write to.

And bug fixes

As usual, we have a few bug fixes in this update…

In some cases the volume of the video player was set to 0 when it should not have been. This should now be fixed.

If you right-clicked a video and selected “assign to bin” from the menu, the video was not moved to the bin as it should have been. Also, we did a pass on the user interface of the assign bin dialog to make it more clear as in some cases the colors made it hard to read.

If you right-clicked a companion image browser it had some menu options incorrectly disabled.

Finally, we fixed an in the keyword manager that prevented keywords to be completely deleted from a catalog.

Setting tags to video files

Video tags and keywords

I will show you how to write tags to video files so they can be searched from Windows file explorer.

In Fast video cataloger, you can assign tags (keywords) to videos as well as to specific points in time inside of the video files. You can quickly search across all your videos even if the video files are archived away and not accessible. Keywords in Fast video cataloger are stored in the catalog and not in the video files. If you want to be able to use Windows search and have the same tags as in Fast video cataloger you need to transfer the tags to the actual video files. Fortunately, this can be easily be done with the integrated script support in Fast video cataloger.

Setting tags to video files

If you don’t care about the details simply copy the script at the bottom of this text into the script window in Fast video cataloger. Select the videos you want to transfer tags to and run the script.

Tags on files in Windows

When you do a search in Windows you search on metadata stored inside files. Windows can build and maintain an index of all this metadata to make searching a bit quicker so that it does not have to access all files every time you search. What metadata you can add to a file depends on the file format. It is not the same for all files and for some file formats it is actually quite limited. For example, not all video file formats support tags. To see what tags are set to a video file, click properties in Explorer and go to the Details tab.

Tags in video file details

Video detail property page

You can also get to the properties from inside Fast video cataloger, just right-click the video in the catalog list and select File/Properties.

If you see a Tags line in the property sheet then the format support Tags. You will also find a rating, title, and a comments field. If the tags field is not there for the file format, that format simply does not support tags. If the format does not support tags then this script will fail when trying to assign tags to it. This is also one of the reasons why Fast video cataloger does not store tags inside of the video files by default.

C# code walkthrough

WindowsAPICodePack

We will use the "Microsoft.WindowsAPICodePack.Shell" package to write the tags to files. To be able to use that package we need to add a reference to it from our project. If you are copying this code for a normal C# project, i.e. not a Fast video cataloger script you can add the reference in the Visual studio solution (look in references). For a script in Fast video cataloger we don’t have a solution, the way we need to do this is with a special comment. The first line in the script adds that reference: //css_ref Microsoft.WindowsAPICodePack;. Then we also need to add the using lines to bring in the library to the file: using Microsoft.WindowsAPICodePack.Shell;. Now that we have solved the extra dependencies we can use this library to write our tags to the videos.

The code

The beginning of this script is very similar to most other Fast video cataloger sample scripts. We get the id of the selected video(s) and then use that id to the path to the file.

The ConvertToLocalPath(...) is needed in case your catalog has used special folders and will convert these special folders into an absolute path. If the path is already absolute this will do nothing.

Then we need to get a shell reference to the file with ShellFile.FromFilePath. In the Windows shell not all entries are files. The shell API references entries in the shell using pidl and not normal file paths. This API call simply gets the path in the shell to the file.

The next step is to get the function to write to the property page of the shell object. file.Properties.GetPropertyWriter(); give us the interface we need and then we only need to call WriteProperty(..) to write property values of the file. For the calls to succeed the property needs to be supported by the file format as mentioned before and the file needs to be writable.

External references

As all other samples this sample is available on the Fast video cataloger github repository.

Documentation on properties for Windows files can be found here

C# code – Tag to video file


//css_ref Microsoft.WindowsAPICodePack;
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using System.Collections.Generic;
using System.Runtime;
using System;
using VideoCataloger;

namespace VideoCataloger
{
  public class WriteTags
  {
    static public void Run(IScripting scripting, string argument)
    {
        scripting.GetConsole().Clear();
        var catalog = scripting.GetVideoCatalogService();
        ISelection selection = scripting.GetSelection();
        List selected = selection.GetSelectedVideos();
        foreach (long video in selected)
        {
          try
          {
            var entry = catalog.GetVideoFileEntry(video);

            IUtilities utilities = scripting.GetUtilities();
            var selected_path = utilities.ConvertToLocalPath(entry.FilePath);

            var file = ShellFile.FromFilePath(selected_path );

            var selected_videos = new long[1];
            selected_videos[0] = video;
            var TagInstances = catalog.GetTagsForVideos(selected_videos);
            List tag_list = new List();
            foreach (var tag in TagInstances)
            {
              tag_list.Add( tag.Name );
            }

            scripting.GetConsole().Write( "Tagging : " + selected_path + " ..." );
            ShellPropertyWriter propertyWriter =  file.Properties.GetPropertyWriter();
            propertyWriter.WriteProperty(SystemProperties.System.Keywords, tag_list.ToArray() );
            int Rating = 0;
            if (entry.Rating==1)
              Rating = 1;
            if (entry.Rating==2)
              Rating = 25;
            if (entry.Rating==3)
              Rating = 50;
            if (entry.Rating==4)
              Rating = 75;
            if (entry.Rating==5)
              Rating = 99;
            propertyWriter.WriteProperty(SystemProperties.System.Rating, Rating );
            propertyWriter.WriteProperty(SystemProperties.System.Comment, entry.Description );
            propertyWriter.Close();

            scripting.GetConsole().WriteLine( "Done " );
          }
          catch (Exception ex)          
          {
            scripting.GetConsole().WriteLine( ex.Message );
          }
        }       
    }
  }
}

Fast video cataloger 6.26

We just uploaded Fast video cataloger to version 6.26, download it from videocataloger.com/downnload/ the download page.

So what is new in this version? The largest change is probably an update to the docking framework which should fix a number of bugs as well as improve performance.

The “Find duplicate videos tool” has been further improved, Select “Clean” from the start menu. We also removed the old tool from the repair dialog.

And, finally, this is pretty small. We added a new shortcut to “refresh search” (Shift + Alt + R). This shortcut just refreshes the current search and is useful if you have added new videos to a catalog after the search.

Media player classic as video player in Fast video cataloger

Media player classic

A really great and free video player is MPC-HC Media player classic home cinema. From their own site:

“MPC-HC is an extremely light-weight, open-source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.”

This post will show you how to use media player classic as a video player in Fast video cataloger? But first, what about the internal video player?

The integrated video player

Fast video cataloger has an integrated video player that can play your video straight from the selected thumbnail. There are a whole lot of ways to configure the video player to your liking. The integrated video player is really great for quickly browsing your video collection and finding what you are looking for. However, if you really want to watch a video from your collection you might want to use an external favorite video player.

Setting up media player classic

First download a stable 64-bit version version of MPC-HC from https://mpc-hc.org/downloads/ and unpack it to a folder (or run the installer). I unpacked the program to this folder:
D:\utils\MPC-HC.1.7.13.x64\ so the path to the video player is: “D:\utils\MPC-HC.1.7.13.x64\mpc-hc64.exe”

Just running mpc-hc64.exe will start it with the normal user interface.

You can also start the video player with command line arguments, if you run the program from the command line with the /? switch you get a list of command-line arguments. Here are the ones we are going to use:

/fullscreen : Start in full-screen mode
/play : Start playing the file as soon the player is launched
/close : Close the player after playback (only works when used with /play)
/startpos : start from a time in the video

So let us say we want to start playing a video c:\video files\sample.avi in fullscreen a minute into the video file. We can do that with the following command line:

“D:\utils\MPC-HC.1.7.13.x64\mpc-hc64.exe” “c:\video files\sample.avi” /startpos 00:01:00 /fullscreen

Notice the path to the video file is in quotes since there is a space in the path.

To use this from Fast video cataloger we need to create a command-line with the selected video and the time of the selected thumbnail. You can do this easily with an action.

Media player classic as an action

Actions are created from the preferences in Fast video cataloger.

In preferences go to the “Action” tab and click the “Add” button to create a new action.
1. Enter a good name for your new action and a tool tip. (Don’t name it Play as then it will collide with the normal play-action)

media player classic action name

Name of video player action

2. Click on the execute tab and browse for the mpc-hc64.exe file.

media player classic executable path

pick the media player classic executable

3. Click on the arguments tab and enter the following line as an argument:
“{video_file}” /startpos {thumb_time} /fullscreen /play
The arguments inside {} will be replaced when the action is executed.
Click “Ok” to create your action.

arguments to media player classic

media player classic arguments

Click OK again to close Preferences. Preferences and actions are stored in your local settings and not per catalog.

In Fast video cataloger click the view button and make sure the action window is visible (the button should be blue).

In the Action window, you can find your new command if you expand the custom actions.

Custom video player action

Find the new video player action in the custom actions section

If you click this button now it will play the currently selected video in fullscreen from the time of the selected thumbnail with the mpc video player.

Shortcut to the media player classic action

Now let’s assign a shortcut to the video player. Click the catalog button and then the shortcut button.

video player shortcut

shortcut for video player

In the shortcut dialog scroll to the bottom of the list and you will find your new “Play MPC” command there. Click on the Key column for the command and enter press your new shortcut. Then Click OK to close the shortcut dialog.