ExifTool Forum

ExifTool => Developers => Topic started by: PaulWilliams on February 11, 2021, 08:25:09 PM

Title: I am seeing a differing order of results between perl and c++
Post by: PaulWilliams on February 11, 2021, 08:25:09 PM

  I have an mp4 file that contains multiple GPS date/time fields.  When I run the command line (perl) version all of my timestamps are reported in time order. 
  When I use the C++ code, not all results are in time order.

If I use the perl command line tool:

exiftool -ee myfile.mp4   |  grep "GPS Date/Time" 

the result is:

GPS Date/Time                   : 2021:02:10 12:22:32.893Z
GPS Date/Time                   : 2021:02:10 12:22:33.893Z
GPS Date/Time                   : 2021:02:10 12:22:34.893Z
GPS Date/Time                   : 2021:02:10 12:22:35.893Z
GPS Date/Time                   : 2021:02:10 12:22:36.893Z
GPS Date/Time                   : 2021:02:10 12:22:37.893Z
GPS Date/Time                   : 2021:02:10 12:22:38.893Z
GPS Date/Time                   : 2021:02:10 12:22:39.893Z

if I user the C++ example1 source and modify on line:
TagInfo *info = et->ImageInfo(argv[1],NULL,5);
becomes:
TagInfo *info = et->ImageInfo(argv[1],"-ee",5);
and call:
example1 myfile.mp4 | grep -A 2 "GPS Date/Time"
the result is:
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:34.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:32.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:33.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:35.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:36.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:37.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:38.893Z
--
  desc = GPS Date/Time
  id = GPSDateTime
  value = 2021:02:10 12:22:39.893Z

Note, in the C++ example time 12:22:34.893Z is before 12:22:32.893Z , whereas in the perl example they are in time order. 

I guess I could parse all of the results and then sort them, but I wander if anything else is appearing out of order (i.e. GPS location information in the case of this file). 

On a related note, is there a way to know what frame in a video file the EXIF data is associated with? 

Cheers

Title: Re: I am seeing a differing order of results between perl and c++
Post by: Phil Harvey on February 11, 2021, 09:59:52 PM
That's odd.  I just tried it here and on a test file and the output was ordered properly.

When you call ExifTool::ImageInfo() with -ee, the actual command is executed with -ee -php -l -G:0:1:2:4 -D -sep ", "

How does the output of this look for your test file?  The order should be the same as returned by ExifTool::ImageInfo().

- Phil
Title: Re: I am seeing a differing order of results between perl and c++
Post by: PaulWilliams on February 11, 2021, 11:09:20 PM


The same mis-ordering there:


exiftool -ee -php -l -G:0:1:2:4 -D -sep ", " ~/DJI/DJI_0087.MP4  | grep -A 2  GPSDate
  "QuickTime:Track3:Time:Copy2:GPSDateTime" => Array(
    "desc" => "GPS Date/Time",
    "id" => "GPSDateTime",
    "val" => "2021:02:10 12:22:34.893Z"
  ),
--
  "QuickTime:Track3:Time:GPSDateTime" => Array(
    "desc" => "GPS Date/Time",
    "id" => "GPSDateTime",
    "val" => "2021:02:10 12:22:32.893Z"
  ),
--
    "val" => "[minor] Approximating GPSDateTime as CreateDate - Duration + SampleTime"
  ),
  "QuickTime:Track3:Video:Copy1:SampleTime" => Array(
--
  "QuickTime:Track3:Time:Copy1:GPSDateTime" => Array(
    "desc" => "GPS Date/Time",
    "id" => "GPSDateTime",
    "val" => "2021:02:10 12:22:33.893Z"
  ),
--
  "QuickTime:Track3:Time:Copy3:GPSDateTime" => Array(
    "desc" => "GPS Date/Time",
    "id" => "GPSDateTime",
    "val" => "2021:02:10 12:22:35.893Z"
  ),
Title: Re: I am seeing a differing order of results between perl and c++
Post by: Phil Harvey on February 12, 2021, 08:53:47 AM
Could you send me the file so I can try this myself (philharvey66 at gmail.com)?

- Phil
Title: Re: I am seeing a differing order of results between perl and c++
Post by: StarGeek on February 12, 2021, 10:51:23 AM
Have you tried running the command without using grep?
exiftool -ee -php -l -G:0:1:2:4 -D -sep ", " -GPSDateTime ~/DJI/DJI_0087.MP4

or to get all GPS tags
exiftool -ee -php -l -G:0:1:2:4 -D -sep ", " -GPS* ~/DJI/DJI_0087.MP4
Title: Re: I am seeing a differing order of results between perl and c++
Post by: PaulWilliams on February 12, 2021, 05:36:42 PM
  Phil,

   I have emailed you a google share link for the file. 

  Both:
exiftool -ee -php -l -G:0:1:2:4 -D -sep ", " -GPSDateTime ~/DJI/DJI_0087.MP4

and
exiftool -ee -php -l -G:0:1:2:4 -D -sep ", " -GPS* ~/DJI/DJI_0087.MP4

  Give the correct ordering. 

  So (without really understanding what is happening inside the code) I guess it is ordering on some other content. 

  By the way,  I see this happening on all of the video files from my DJI Mini 2

  Thanks again for your help. 
   Regards
   Paul
Title: Re: I am seeing a differing order of results between perl and c++
Post by: Phil Harvey on February 13, 2021, 11:42:51 AM
Hi Paul,

OK.  I see what is happening.  Bottom line:  Add --sort to your command to get what you want.

The problem is that the tags are sorted by group according to the -G:0:1:2:4 option, and other tags in the Time group of Track3 are messing with the sort order for your GPSDateTime tags.

- Phil
Title: Re: I am seeing a differing order of results between perl and c++
Post by: PaulWilliams on February 15, 2021, 12:02:23 AM


Phil,

  Thank you very much for your help with this.