Wrong decode when print the table structure

Started by kingvhit, August 13, 2020, 11:00:29 AM

Previous topic - Next topic

kingvhit

Hi,

I have ran bellow command to get the tagId and table based structure of metadata set. All of this working well, but some tag has an ID like this is return wrong character after ran.

My commands.
exiftool -T -G -H -x ExifTool:all -x Composite:all -x MakerNotes:all -api largefilesupport=1 -sort -json VID_20200813_210243.mp4 > data.json

Json data

[{
  "SourceFile": "VID_20200813_210243.mp4",
  "QuickTime:GPSCoordinates": {
    "id": "?xyz",
    "table": "QuickTime::UserData",
    "val": "16 deg 4' 3.00\" N, 108 deg 12' 42.48\" E"
  },
}]


The correct point of `id` must be `\xa9xyz`, but it return "?xyz", tried to add UTF8 as charset not works.

Thank you!

Phil Harvey

The tag ID is binary (ie. it can't be converted to UTF-8).  Try adding the -b option to your command.

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

kingvhit

Hi thank you, I got the value of this, but may I got some other issue

I tried bellow command to get all of the available Tag on ExifTool.
See

exiftool -listx -s -f -csv > all.xml


That will return the data of QuickTime table

<table name='QuickTime::UserData' g0='QuickTime' g1='UserData' g2='Video'>
<tag id='\xa9xyz' name='GPSCoordinates' type='string' writable='true' g2='Location'/>
</table>


Then, I save all of the tag on my local DB and modify to make something, but the above command that I got from base64 like this

  "QuickTime:GPSCoordinates": {
    "id": "base64:qXh5eg==",
    "table": "QuickTime::UserData",
    "val": "16 deg 4' 3.00\" N, 108 deg 12' 42.48\" E"
  },


Convert base64 I got only `xyz` so I can't identify this tag on my local DB because the ID is not same, and so many other tags has same `xyz` value, so I can't use `like` operator to compare this.

Do you have any idea for this, thank you!

kingvhit

Depend on duplicate tag in the same tableName, I can't use the `tagName` for identify a tag.




dae65

This Perl script will use the API to print a table from groups and IDs to values using tab as a column separator:

use v5.10;
use Image::ExifTool 12.04;
my $et = new Image::ExifTool;
my $groups = shift;
binmode STDOUT, ':utf8';
for ( @ARGV ) {
  if ( $et->ExtractInfo ( $_ ) ) {
    foreach my $group ( split /,/, $groups ) {
      my $by_name = $et->GetInfo ( { Group1 => $group } ) or next;
      say STDOUT join "\t", $group, $et->GetTagID ($_), $by_name->{$_} for keys %$by_name;
    }
  }
}


Save it to some script.pl file, and either make it executable or run it with Perl:
$ perl script.pl ItemList,UserData file.mp4
The second argument is a comma-separated list of family 1 groups.

If you really need to output it as json, make sure JSON::XS is installed first, and let me know.

Phil Harvey

QuoteThat will return the data of QuickTime table

    "id": "base64:qXh5eg==",


Convert base64 I got only `xyz`

You're converting it wrong.  This is what I get:

% echo qXh5eg== > t1
% cat t1
qXh5eg==
% base64 -D t1 > t2
% hexdump t2
    0000: a9 78 79 7a                                     [.xyz]


Also, the -csv option has no effect on the -listx output.

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

kingvhit

Quote from: dae65 on August 14, 2020, 02:11:47 PM
This Perl script will use the API to print a table from groups and IDs to values using tab as a column separator:

use v5.10;
use Image::ExifTool 12.04;
my $et = new Image::ExifTool;
my $groups = shift;
binmode STDOUT, ':utf8';
for ( @ARGV ) {
  if ( $et->ExtractInfo ( $_ ) ) {
    foreach my $group ( split /,/, $groups ) {
      my $by_name = $et->GetInfo ( { Group1 => $group } ) or next;
      say STDOUT join "\t", $group, $et->GetTagID ($_), $by_name->{$_} for keys %$by_name;
    }
  }
}


Save it to some script.pl file, and either make it executable or run it with Perl:
$ perl script.pl ItemList,UserData file.mp4
The second argument is a comma-separated list of family 1 groups.

If you really need to output it as json, make sure JSON::XS is installed first, and let me know.

Awesome, I got the value as expected by string `@xyz`, thank a lot. Thought that I don't have a file to test on the other tag id, but that seem like works.

@Phil Harvey: Thank for you correct point!!