Sorting video files by length categories

Started by Christos, May 24, 2025, 06:38:30 PM

Previous topic - Next topic

Christos

Hi there,

I'm sorry if this has been answered elsewhere; I couldn't find it myself.

I am struggling with the following. I have a large database of video files of varying lengths, ranging from a few seconds to several hours. I want to sort them into categories, for example, all videos under 15 minutes, videos between 15 and 90 minutes, and so on. I haven't decided on the exact categories yet, but I need the functionality to do this. I'm struggling to see how to achieve it.

The videos are standard files (avi, mp4, mpg etc.).

Any help would be welcome, or perhaps a pointer to where this has been discussed.

Thanks!

Mario

#1
This is not easy to do, unfortunately.
There is no standard tag to record the duration/length of a video. QuickTime alone uses maybe 6 or 8 different tags for length information, depending on the QuickTime version.
AVI uses other tags, and a video container can contain multiple video streams with different duration values.
Video metadata is an even bigger mess than image metadata.

Luckily, IMatch stores the length of a video file (in seconds) in the database when it processes the video to generate the thumbnails. IMatch uses this value e.g. in the "Video" File Window layout. IMatch also makes this duration value available via the {File.Duration} variable.

You can utilize that to create a data-driven categoriy based on this variable like so:

You cannot view this attachment.

This should do the trick (good that you have IMatch).

Make sure to read Data-driven Categories Based on Variables, especially the big yellow warning box.
Data-driven categories based on variables are a powerful problem solver, but come at a (performance) price.
Use a file format filter, make the category manual update etc.

Christos

Thank you, Mario! Appreciated.
I will follow your advice. If I am stuck I might come back with further questions. Bear with me!

 ::)

Mario

Use the settings I showed in my screen shot and you're 90% there. Set numeric ranges as needed.

Mario

An additional tip: You can group the variable values using the numcomp function. For example:

{File.Duration|cast:int;numcomp:lt,30,Short;numcomp:lt,500,Medium;numcomp:gt,500,Long}

We compare less than 30 (seconds), less than 500 (seconds) and greater than 500 (seconds) to group videos into "Short", "Medium" and "Long". This variable, when used for a data-driven category, creates 3 child categories: Short, Medium and Long and assigns files to these categories based on duration.

Take that as a starting point.