ExifTool in Custom Thumbnail

Post Reply
Bongo
Posts: 58
Joined: 22 Mar 10 19:11
Location: Ingolstadt, Germany
Contact:

ExifTool in Custom Thumbnail

Post by Bongo » 14 Jul 21 17:30

I installed ExifTool. I use it for videos. For example, to display the frame rate in the custom thumbnail.
The "ExifTool Metadata Output" script returns the result:
hc_806.png
hc_806.png (8.77 KiB) Viewed 281 times
When I enter %ExifTool:VideoFrameRate in Custom Thumbnail, it remains empty.

It ever worked. I'm not sure but I think it does not work for V6 anymore.
Regards, Bongo
Photo Supreme V6 Single User Edition, Windows 10.

Hert
Posts: 6874
Joined: 13 Sep 03 7:24

Re: ExifTool in Custom Thumbnail

Post by Hert » 15 Jul 21 20:35

Please update to build 3801 for a fix.

And while you're at it; after installing 3801; try this as a custom thumb line. It is faster than calling ExifTool for that.

Code: Select all

Video Frame Rate: %code

	function VideoFrameRate: Single
	var
	  ATif: TTif;
	begin
	  result := -1;
	  ATif := TTif.Create(nil);
	  try
	    ATif.FileName := ImageItem.ExifFileName;
	    ATif.DataSizeLimit := 128;
	    ATif.Load(True, True);

	    if Assigned(ATif.VideoHeader) then
	      result := ATif.VideoHeader.FrameRate;
	  finally
	    ATif.Free;
	  end;
	end;

var
  AExt: WideString;
  AFps: Single;
begin
  AExt := ImageItem.FileNameExtensionOnly;
  if WideSameText(AExt, 'MOV') or
     WideSameText(AExt, 'M4V') or
     WideSameText(AExt, 'MP4') or
     WideSameText(AExt, '360') or
     WideSameText(AExt, 'AVI')
  then
  begin
    AFps := RoundToPrecision(VideoFrameRate, 3);
    if AFps < 0 then
      result := ''
    else
      result := FloatToStr(AFps);
  end
  else
    result := '';
end;
%/code
This is a user-to-user forum. If you need product support then please send a message

Bongo
Posts: 58
Joined: 22 Mar 10 19:11
Location: Ingolstadt, Germany
Contact:

Re: ExifTool in Custom Thumbnail

Post by Bongo » 16 Jul 21 13:43

Cool, the problem is fixed.
The code is also cool. That's a lot faster.
My custom thumbnail for video looks like this:
hc_809.png
hc_809.png (11.11 KiB) Viewed 199 times

Code: Select all

<font family="tahoma">%FileExtension{uppercase=y}</font>   <font family="tahoma" color="#CCFFFF00">%ImageFileSizeShort</font>   <font family="tahoma">%dd %mmm %yyyy</font>
<font family="tahoma">%exiftool:VideoFrameRate FPS</font>   <font family="tahoma" color="#CCFFFF00">%exiftool:AvgBitrate</font>   <font family="tahoma" color="#CCFFFF00">%exiftool:MediaDuration</font>
<font family="tahoma">Zeit: %exiftool:ShutterSpeedValue</font>   <font family="tahoma" color="#CCFFFF00">Blende: %exiftool:Aperture</font>   <font family="tahoma" color="#CCFFFF00">ISO: %exiftool:ISO</font>
<font family="tahoma">BW: %exiftool:FocalLength</font>   <font family="tahoma" color="#CCFFFF00">Format: %exiftool:ImageSize</font>   <font family="tahoma" color="#CCFFFF00">%exiftool:Make</font>
I also wanted the code for Avgbitrate, Mediaduration, ShutterspeedValue, Aperture, ISO, Focallength and ImageSize.

I just replaced this line in your code:
result := ATif.VideoHeader.AvgBitrate;
There is this error message:
hc_811.png
hc_811.png (15.99 KiB) Viewed 199 times

It does not seem to be as easy as I thought. How can I display the other video data without an ExifTool?
Regards, Bongo
Photo Supreme V6 Single User Edition, Windows 10.

Hert
Posts: 6874
Joined: 13 Sep 03 7:24

Re: ExifTool in Custom Thumbnail

Post by Hert » 17 Jul 21 8:33

In the latest 3808 build, PSU also reads the length of the video. See below for a macro that you can use for that

If you can send me a sample video that holds all the details (like ISO, etc) then when I have some time I may add more support. But in general you should be able to use the standard XMP macros for these general field.

Shutter Speed: %xmp:exif:ShutterSpeedValue (better to use Exposure Time instead)
Exposure Time: %xmp:exif:ExposureTime
Aperture: %xmp:exif:ApertureValue (but better to use the F-Number instead)
F-Number: %xmp:exif:FNumber
ISO: %xmp:exif:ISOSpeedRatings
Focal Length: %xmp:exif:FocalLength
Dimensions: %ImageDimension

TIP; use the drop down for each custom field to find the macros.

Video Duration:

Code: Select all

Video Duration: %code

	function VideoDuration: TDateTime
	var
	  ATif: TTif;
	begin
	  result := 0.0;
	  ATif := TTif.Create(nil);
	  try
	    ATif.FileName := ImageItem.ExifFileName;
	    ATif.DataSizeLimit := 128;
	    ATif.Load(True, True);

	    if Assigned(ATif.VideoHeader) then
	      result := ATif.VideoHeader.Duration;
	  finally
	    ATif.Free;
	  end;
	end;

var
  AExt: WideString;
  ADuration: TDateTime;
begin
  AExt := ImageItem.FileNameExtensionOnly;
  if WideSameText(AExt, 'MOV') or
     WideSameText(AExt, 'M4V') or
     WideSameText(AExt, 'MP4') or
     WideSameText(AExt, '360') or
     WideSameText(AExt, 'AVI')
  then
  begin
    ADuration := VideoDuration;
    //ShowMessage(TimeToStr(ADuration));
    if ADuration = 0.0 then
      result := ''
    else
    begin
      if SecondsBetween(0.0, ADuration) < 60 then
      begin
        //result := GetDurationString(ADuration, [dpDays, dpHours, dpMinutes, dpSeconds, dpMilliseconds], True, True);
        result := FloatToStr(RoundToPrecision(MilliSecondsBetween(0.0, ADuration) / 1000, 2)) + 's';
      end
      else
        result := TimeToStr(ADuration);
    end;
  end
  else
    result := '';
end;
%/code
This is a user-to-user forum. If you need product support then please send a message

Bongo
Posts: 58
Joined: 22 Mar 10 19:11
Location: Ingolstadt, Germany
Contact:

Re: ExifTool in Custom Thumbnail

Post by Bongo » 24 Jul 21 15:44

Thank you, the code works.

The standard XMP macros do not work. That's why I wanted to do it with ExifTool. If this would work one does not need ExifTool and the long code.
%ImageDimension brings a wrong value. Probably the integrated preview.

I have provided videos from different cameras. Would be nice if you could adapt it.
[edit hert; downloaded the files and removed the link]


Last bumped by Bongo on 24 Jul 21 15:44.
Regards, Bongo
Photo Supreme V6 Single User Edition, Windows 10.

Post Reply