Click or drag to resize

Reading extended properties

What are extended properties and how to you read them?

Extended properties

Extended properties are added in Fast video indexer when you index a video file and has set in the video indexer tab to add xmp and other extra metadata.

Extended properties are stored as strings in the catalog.

The properties we discussed in the previous section, like path and title, are available for all videos. FVC also lets you define your video properties, which we call extended properties.

Extended properties are used to store extracted metadata, including XMP data. The extended properties are stored as separate entries that you need to read explicitly. In FVC, you can view extended properties in a list at the bottom of the video detail window.

C#
ExtendedProperty[] GetVideoFileExtendedProperty( int video_file_id )

Give you all extended properties for a given video. [] is how you define an array in C#, so we get back a zero-based array of extended properties.

An extended property class is a key value pair with a Property and a Value. Here is how you would get an extended property from a video:

C#
ExtendedProperty[] props = catalog.GetVideoFileExtendedProperty((int) VideoID);

Note that the interface wants an int VideoID. VideoIDs are always zero-based positive numbers, but some APIs use a negative value to indicate an invalid ID and need a signed number. Sometimes you need a VideoID as a signed integer and sometimes as an unsigned. You can convert between them with the cast operators, (int) will cast to a signed integer id.

Now to print all extended properties for a video we can again use a foreach loop like this:

C#
ExtendedProperty[] props = catalog.GetVideoFileExtendedProperty( (int) VideoID );
foreach (ExtendedProperty p in props)
{
  scripting.GetConsole().WriteLine( p.Property + " - " + p.Value  );
}

And here is the complete program to print all extended properties for the currently selected videos:

C#
using System.Runtime;
using System.Collections.Generic;
using VideoCataloger;
using VideoCataloger.RemoteCatalogService;

class Script
{
  static public async System.Threading.Tasks.Task Run ( IScripting scripting, string arguments ) 
  {
    ISelection selection = scripting.GetSelection();
    List<long> selected_videos = selection.GetSelectedVideos();
    IVideoCatalogService catalog = scripting.GetVideoCatalogService();
    IUtilities utils = scripting.GetUtilities();

    foreach (long VideoID in selected_videos)
    {
      VideoFileEntry entry = catalog.GetVideoFileEntry( VideoID );
      string path = utils.ConvertToLocalPath(entry.FilePath);
      scripting.GetConsole().WriteLine( path  );
      
      ExtendedProperty[] props = catalog.GetVideoFileExtendedProperty((int) VideoID);
      foreach (ExtendedProperty p in props)
      {
        scripting.GetConsole().WriteLine( p.Property + " - " + p.Value  );
      }
    }
  }
}

If you want to set a property use SetVideoFileExtendedProperty, with the printed property above.

C#
void SetVideoFileExtendedProperty(
    int video_file_id,
    string property,
    string value
)

In summary, you can read extended properties from the IVideoCatalogService Interface that you get by calling GetVideoCatalogService().

GetAllExtendedPropertyValues() gets you a specific extended property for all videos.

GetVideoFileExtendedProperty() gets you all extended properties for a specific video.