Compare subject and keywords

Started by Fulco, October 30, 2015, 06:53:56 PM

Previous topic - Next topic

Fulco

I've embedded in some hundreds of movie files XMP and QuickTime keywords. Sometimes the keyword and subject string are different. For example:


MacBook-Air-van-Fulco:~ Fulco$ exiftool -a -G1 -s -keywords -subject /Users/Fulco/Pictures/20150328_082413.mov
[QuickTime]     Keywords                        : The Netherlands, Wildlife, Bird, Birds of Prey
[XMP-dc]        Subject                         : The Netherlands, Wildlife, Bird, Birds of Prey, Goshawk


Is it possible with Exiftool to filter out those videos with a keyword and subject string which don't compare to each other?

StarGeek

You could try something like:
ExifTool -if '$Keywords ne $Subject' -Keywords -Subject FILEorDIR

That will give you a list where Keywords are not exactly equal to Subject.  But take note that it will also give you cases where the two items have the same keywords, but in different order.   For example, if keywords is "The Netherlands, Wildlife, Bird, Birds of Prey" and Subject is "The Netherlands, Birds of Prey, Wildlife, Bird" this will be considered different, even though the actual keywords are the same.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Fulco

Thank you for your prompt reply. I tried also if a combination would work:

exifTool -if '$QuickTime:Model ne $XMP:Model' -if '$QuickTime:Make ne $XMP:Make' -QuickTime:Model -XMP:Model  -QuickTime:Make -XMP:Make

This command only filters files when both values of Make and Model are not equal: Model A and Model B, Make A and Make B. The command doesn't filter files when one of the two values don't compare to each other: Model A and Model B, Make A and Make A. Is there a way to do this in a single operation?

Thanks in advance,
Fulco

Phil Harvey

Hi Fulco,

Multiple -if statements are combined with a logical "and", but I think you want an "or":

exifTool -if '$QuickTime:Model ne $XMP:Model or $QuickTime:Make ne $XMP:Make' -QuickTime:Model -XMP:Model  -QuickTime:Make -XMP:Make DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Fulco

Now I can verify if a tag is present and if the tag values are equal:

exiftool -if 'not $QuickTime:Make or not $XMP:Make or not $QuickTime:Model or not $XMP:Model or not $QuickTime:Software or not $XMP:Software or not $Composite:GPSLatitude or not $XMP:GPSLatitude or not $Keywords or not $Subject or $QuickTime:Make ne $XMP:Make or $QuickTime:Model ne $XMP:Model or $QuickTime:Software ne $XMP:Software or $Composite:GPSLatitude ne $XMP:GPSLatitude or $Composite:GPSLongitude ne $XMP:GPSLongitude or $Keywords ne $Subject' -a -G1 -s -Directory -Filename -QuickTime:Make -XMP:Make -QuickTime:Model -XMP:Model -QuickTime:Software -XMP:Software -QuickTime:Keywords -XMP:Subject -c "%+.6f" -XMP:GPSLatitude -XMP:GPSLongitude -Composite:GPSLatitude -Composite:GPSLongitude -ext mov -r

Thanks for this great tool. It is important for my media management. Donation is already given.

Fulco

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Fulco

Conditionally searching doesn't work for files which are re-encoded with Compressor (Apple). This app preserves QuickTime and XMP metadata from the source file in the re-encoded file. When the tag values of this file are actually equal they should not be filtered as not equal. Also tags which are present should not be filtered as not present:


MacBook-Air-van-Fulco:~ Fulco$ exiftool -if 'not $QuickTime:Make or not $XMP:Make or not $QuickTime:Model or not $XMP:Model or not $QuickTime:Software or not $XMP:Software or not $Composite:GPSLatitude or not $XMP:GPSLatitude or not $Keywords or not $Subject or $QuickTime:Make ne $XMP:Make or $QuickTime:Model ne $XMP:Model or $QuickTime:Software ne $XMP:Software or $Composite:GPSLatitude ne $XMP:GPSLatitude or $Composite:GPSLongitude ne $XMP:GPSLongitude or $Keywords ne $Subject' -a -G1 -s -Filename -QuickTime:Make -XMP:Make -QuickTime:Model -XMP:Model -QuickTime:Software -XMP:Software -QuickTime:Keywords -XMP:Subject -c "%+.6f" -XMP:GPSLatitude -XMP:GPSLongitude -Composite:GPSLatitude -Composite:GPSLongitude -ext mov -r /Users/Fulco/Pictures/20120902103830.mov
[System]        FileName                        : 20120902103830.mov
[QuickTime]     Make                            : SONY
[XMP-tiff]      Make                            : SONY
[QuickTime]     Model                           : DSC-HX5V
[XMP-tiff]      Model                           : DSC-HX5V
[QuickTime]     Software                        : ClipWrap, Compressor
[XMP-tiff]      Software                        : ClipWrap, Compressor
[QuickTime]     Keywords                        : Zuid-Afrika, Kruger National Park, Vogel, Southern Ground Hornbill, Zuidelijke hoornraaf, MapEF
[XMP-dc]        Subject                         : Zuid-Afrika, Kruger National Park, Vogel, Southern Ground Hornbill, Zuidelijke hoornraaf, MapEF
[XMP-exif]      GPSLatitude                     : -25.062925
[XMP-exif]      GPSLongitude                    : +31.895002
[Composite]     GPSLatitude                     : -25.062925
[Composite]     GPSLongitude                    : +31.895002


Any idea why this is happening?

Fulco

Phil Harvey

Hi Fulco,

If you send me the MOV I'll take a look.  I suspect that there may be some invisible characters that are causing the difference.  My email is philharvey66 at gmail.com

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

I got the file, thanks.

> exiftool ~/Desktop/20120902103830.mov -quicktime:make -b >t1
> exiftool ~/Desktop/20120902103830.mov -xmp:make -b >t2
> diff t1 t2
Binary files t1 and t2 differ
> hexdump t1
    0000: 53 4f 4e 59 00                                  [SONY.]
> hexdump t2
    0000: 53 4f 4e 59                                     [SONY]


I'll see what I can do about removing the trailing null when the QuickTime value is extracted.

According to the QuickTime specification, these values should be stored without a NULL terminator, which is why ExifTool doesn't remove it.  But obviously some people (Sony programmers) can't read the specification.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Fulco

The file is originally a mts/m2ts file which is rewrapped into a MOV wrapper. In this MOV file I embedded XMP and QuickTime metadata. With the command I posted above I can verify if the metadata values are identical or not. When re-encode the MOV file with Compressor then the problem happens as I described. You still think it is a problem from Sony?

I've got another question as well. In MOV files two different QuickTime metadata keys for geographical location data are embedded:"©zyx" and "com.apple.quicktime.location.ISO6709". Sometimes the geolocation values of these two keys are different:


MacBook-Air-van-Fulco:~ Fulco$ exiftool -a -G1 -s -c "%+.10f" -GPSCoordinates -GPSPosition /Users/Fulco/Pictures/20141101161322.mov
[QuickTime]     GPSCoordinates                  : +52.3505796667, +4.9583223333
[QuickTime]     GPSCoordinates                  : -24.8366909027, +31.8095188141
[Composite]     GPSPosition                     : -24.8366909027, +31.8095188141


The Composite:GPSPosition value is derived from the ©zyx key and one of the QuickTime:GPSCoordinates is derived from it as well. GPSPosition and GPSCoordinates always match when this command is used:

exiftool -if '$QuickTime:GPSCoordinates ne $Composite:GPSPosition' -a -G1 -s -Filename -c "%+.6f" -GPSCoordinates -GPSPosition -ext mov -r

I suspect they always match because the value from the tag GPSCoordinates is also derived from the ©zyx key.

Is there a method to verify whether or not QuickTime:GPSCoordinates derived from the ©zyx key and QuickTime:GPSCoordinates derived from the com.apple.quicktime.location.ISO6709 key are equal?

Thanks in advance,

Fulco

Phil Harvey

Hi Fulco,

Whatever software wrote the "Sony" Make tag is doing it wrong.  It sounds from your description that it may not be the Sony software after all.

You should be able to access duplicate QuickTime:GPSCoordinates by specifying a copy number, something like this would process files where these differ:

exiftool -if '$gpscoordinates and $copy1:gpscoordinates and $gpscoordinates ne $copy1:gpscoordinates' ...

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Fulco

Yes, that worked! Thank you very much.