I am seeing a differing order of results between perl and c++

Started by PaulWilliams, February 11, 2021, 08:25:09 PM

Previous topic - Next topic

PaulWilliams


  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


Phil Harvey

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
...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 ($).

PaulWilliams



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"
  ),

Phil Harvey

Could you send me the file so I can try this myself (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 ($).

StarGeek

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
* 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).

PaulWilliams

  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

Phil Harvey

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
...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 ($).

PaulWilliams