This one displays the length of all video files in a folder in a custom column.
It uses:
a.) System installed codecs (very fast)
A codec package helps in this case, e.g. the K-Lite Codec Pack
http://www.codecguide.com/download_kl.htm
The basic package should work just fine
or if a codec for a specific video format isn't installed
b.) MediaInfo: https://mediaarea.net/en/MediaInfo/Download/Windows
You need the CLI version of it!
Necessary changes inside the snippet:
Code: Select all
$mediaInfo = "<xydrive>\Tools\@Command Line Tools\MediaInfo\MediaInfo.exe";
The snippet code:
Code: Select all
Snip: CustomColumn 1
XYplorer 18.90.0000, 22.03.2018 09:46:17
Action
ConfigureColumn
Caption
Video length
Type
3
Definition
$nsecs = property("System.Media.Duration", <cc_item>);
// Use mediainfo for unknown codecs ($nsecs is empty!)
if ($nsecs == "") {
$mediaInfo = "<xydrive>\Tools\@Command Line Tools\MediaInfo\MediaInfo.exe";
$length = regexreplace(runret("$mediaInfo --Inform=General;%Duration/String3% ""<cc_item>"""), "\.\d*\r?\n");
return $length;
// Use system properties for known codecs
} else {
// To get real seconds from nanoseconds, multiply the value with 0.0000001
$secs = round($nsecs * 0.0000001);
// Calculate length
// Do we have a playtime in hours?
$hours = $secs / 3600;
if ($hours >= 1) {
$hours = format(regexmatches($hours, "^\d+"), "00");
$secs = $secs - $hours * 3600;
} else { $hours = "00"; }
// Playtime only in minutes
$mins = $secs / 60;
if ($mins >= 1) {
$mins = format(regexmatches($mins, "^\d+"), "00");
$secs = $secs - $mins * 60;
} else { $mins = "00"; }
// -> Playtime is only seconds
// Nothing to calculate here any more
return $hours . ":" . $mins . ":" . format($secs, "00");
}
Format
0
Trigger
1
Item Type
0
Item Filter
{:Video}