Click or drag to resize

Reading video properties

How to read properties from videos

Reading Video properties

As mentioned before, each video in FVC has a unique ID. From this id, we can access and change data about the video.

Now, we need to access the actual video catalog interface. As before, we can get this interface from the scripting interface, and the interface we want is IVideoCatalogService.

C#
IVideoCatalogService catalog = scripting.GetVideoCatalogService();

The IVideoCatalogService interface has a lot of functions. It has its own section in the documentation. I highly recommend you browse it to get an idea of the functionality available.

This interface is the same as is used by the Fast video cataloger. The FVC software user interface is a separate executable that communicates with the video database through this interface. The actual catalog is running in a separate process. If you are running with a server, it might even run on a different computer.

Now that we have the catalog interface, let us see what we can find out about a video. We need to use the GetVideoFileEntry() function.

C#
VideoFileEntry entry = catalog.GetVideoFileEntry(1);

The 1 argument is the video id, and we get back an entry class with info about the video. If the video ID does not exist in the catalog, you will get a null value.

Look in the documentation for the VideoFileEntry class for all the information available about the video through this interface. One of the properties is the FilePath, i.e., the path to the video file.

Let's try to print the path to the video in the console window. From the previous section, we know how to get the console interface where we can print text.

C#
scripting.GetConsole().WriteLine( entry.FilePath );

We also had a list of selected video ids.

We can use a for each loop to loop over a list in C#. For each will execute the content inside the loop once for each entry in the list

C#
foreach (long VideoID in selected_videos)
{
// Executed once for each entry in the selected_videos list
}

Inside the loop, we have a VideoID. Any line that starts with // is a comment, and all text between the // and the end of the line is skipped.

So, let's put the lines from above inside the loop, and we will print the path of each selected video.

C#
   foreach (long VideoID in selected_videos)
    {
      VideoFileEntry entry = catalog.GetVideoFileEntry( VideoID );
      scripting.GetConsole().WriteLine( entry.FilePath );
    }