Page 1 of 1

Video Length Column

Posted: 21 Mar 2018 17:28
by xyramzi
I upgraded to Windows 10 64 bit and reinstalled a fresh copy of XYPlorer. In the previous setup, I had a column that showed the length of videos and I can't recall how I managed to get it there. Now I went through all the Configuration items looking for it but found nothing.

Can you please tell me how I can get that column back?
Regards,
Ramzi

Re: Video Length Column

Posted: 21 Mar 2018 17:41
by highend
Two ways, mediainfo (cli version!) + adapt the path to it. Works with probably all video formats.
Drawback: Rather slow...

Code: Select all

Snip: CustomColumn 1
  XYplorer 18.90.0000, 21.03.2018 17:31:45
Action
  ConfigureColumn
Caption
  Video length
Type
  3
Definition
   $mediaInfo = "<xydrive>\Tools\@Command Line Tools\MediaInfo\MediaInfo.exe";
   $length = regexreplace(runret("$mediaInfo --Inform=General;%Duration/String3% ""<cc_item>"""), "\.\d*\r?\n");
   return $length;
Format
  0
Trigger
  1
Item Type
  0
Item Filter
  avi;flv;mkv;mp4

The second way: Using system properties (only works on files for that you have a codec installed).
Pro: Very fast...

Code: Select all

Snip: CustomColumn 1
  XYplorer 18.90.0000, 21.03.2018 17:36:43
Action
  ConfigureColumn
Caption
  Test
Type
  3
Definition
      $nsecs  = property("System.Media.Duration", <cc_item>);
      // To get real seconds, multiply the value with 0.0000001
      $secs   = round($nsecs * 0.0000001);

      // We got a real value (playtime >= 1 second)
      if ($secs) {
          // 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
          $length = $hours . ":" . $mins . ":" . format($secs, "00");
      }
      // With no codec, $secs will be 0 -> Playtime is unknown!
      else { $length = ""; }
      return $length;
Format
  0
Trigger
  1
Item Type
  0
Item Filter
  avi;flv;mkv;mp4
  
Such a snippet can be installed by executing:

Code: Select all

::snippet;
from the address bar and copy the snippet code in there...

This doesn't belong into the bug report section, topic moved...

Re: Video Length Column

Posted: 22 Mar 2018 04:27
by RalphM
Did you do a fresh install on purpose?
Otherwise you could just have copied the whole XY installation over from your old installation and this would have retained all your settings.

Re: Video Length Column

Posted: 22 Mar 2018 09:59
by highend
A combined version (best of both worlds)...

Only uses mediainfo where necessary, for installed codecs it uses the system properties

You need to:
a.) Use the correct path to mediainfo here:

Code: Select all

$mediaInfo = "<xydrive>\Tools\@Command Line Tools\MediaInfo\MediaInfo.exe";
Nothing more to configure...

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}


Re: Video Length Column

Posted: 24 Mar 2018 11:40
by xyramzi
Thank you all for the response. I'm not that good a user but I'll have a go and if it still doesn't work, I'll give up.. lol