Page 1 of 1

Video files are sorted by length in wrong order

Posted: 08 Oct 2021 09:03
by luoruiming
Video files are sorted by length in wrong order. For example, when sorted by length, a 2-hour video display is shorter than a 3-minute video display.

Re: Video files are sorted by length in wrong order

Posted: 08 Oct 2021 09:20
by highend
XY is not aware of what kind of data is returned by that video length property and doesn't know how to sort it correctly

Use a custom column with a script instead. That should be sortable (at least for videos not larger than 24 hours)

Code: Select all

    $nsecs = property("System.Media.Duration", <cc_item>);

    // To get real seconds from nanoseconds
    $secs = round($nsecs * 0.0000001);

    $hours = $secs / 3600;
    if ($hours >= 1) {
        $hours = format(regexmatches($hours, "^\d+"), "00");
        $secs  = $secs - $hours * 3600;
    } else { $hours = "00"; }

    $mins = $secs / 60;
    if ($mins >= 1) {
        $mins = format(regexmatches($mins, "^\d+"), "00");
        $secs = $secs - $mins * 60;
    } else { $mins = "00"; }

    return $hours . ":" . $mins . ":" . format($secs, "00");