Author Topic: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?  (Read 381 times)

dae65

  • Full Member
  • ***
  • Posts: 77
Hi,

How can I use the Image::ExifTool Perl module to create, delete, and edit QuickTime ItemList tags directly, instead of XMP tags, in MP4 audio files? I was able to set Album to 'My Album' using the following Perl script:

Code: [Select]
#!/usr/bin/perl
use Image::ExifTool;
my $file = 'file.m4a';
my $exiftool = new Image::ExifTool($file);
$exiftool->SetNewValue (Album=>'My Album');
$exiftool->WriteInfo($file);

However, "My Album" was written as an XMP tag instead of an ©alb MP4 tag. The existing ©alb was left unchanged. I get the same result using the command-line tool.
Code: [Select]
00414920  69 63 4d 65 64 69 61 2f  27 3e 0a 20 20 3c 78 6d  |icMedia/'>.  <xm|
00414930  70 44 4d 3a 61 6c 62 75  6d 3e 4d 79 20 41 6c 62  |pDM:album>My Alb|
00414940  75 6d 3c 2f 78 6d 70 44  4d 3a 61 6c 62 75 6d 3e  |um</xmpDM:album>|
Is it possible to somehow force Image::ExifTool to write MP4 tags?

Thank you.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4074
From the "set a tag in a specific group" example on the Image::ExifTool docs page.

# set a tag in a specific group
$exifTool->SetNewValue(Headline => $val, Group => 'XMP');
$exifTool->SetNewValue('XMP:Headline' => $val);  # (equivalent)


Use either example but instead of XMP set it to ItemList.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

dae65

  • Full Member
  • ***
  • Posts: 77
Thank you very much. This is not working, though. The ExifTool homepage as well as the manpages to Image::ExifTool (v10.40) say that support to MP4 is Read/Write. However,

Code: [Select]
$exifTool->SetNewValue(Group => 'ItemList', 'albm' => 'My Album');
Fails and returns an error string saying that:
Code: [Select]
Sorry, Group is not writable
Strangely, the documentation about QuickTime ItemList tags seems to imply that those tags are writable. But are they? Am I misreading the documentation?

Thanks again.  :)

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4074
Use the tag name, not the tag ID.  You had the name right the first time.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

dae65

  • Full Member
  • ***
  • Posts: 77
Using the tag name instead of the ID fails as well, but now the error string says that:
Code: [Select]
Tag 'ItemList:Album' is not defined :-\

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17044
    • ExifTool Home Page
Upgrade your version of ExifTool.

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

dae65

  • Full Member
  • ***
  • Posts: 77
Thanks.

dae65

  • Full Member
  • ***
  • Posts: 77
Just a quick note: I'd like to warn users against a mistake of mine above. This is wrong:

Code: [Select]
$exifTool->SetNewValue(Group => 'ItemList', Album => 'My Album');
The order of the arguments matters. It should be:

Code: [Select]
$exifTool->SetNewValue(Album, 'My Album', Group => 'ItemList' );
since the SetNewValue method seems to take, not an associative array (hash), but a regular array as an argument.

Thanks.