ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: dae65 on July 13, 2020, 04:58:27 PM

Title: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: dae65 on July 13, 2020, 04:58:27 PM
Hi,

How can I use the Image::ExifTool (https://metacpan.org/pod/Image::ExifTool) Perl module to create, delete, and edit QuickTime ItemList (https://exiftool.org/TagNames/QuickTime.html#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:


#!/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.

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.
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: StarGeek on July 13, 2020, 05:12:54 PM
From the "set a tag in a specific group" example on the Image::ExifTool docs page (https://exiftool.org/ExifTool.html#SetNewValue).

# 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.
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: dae65 on July 13, 2020, 07:29:39 PM
Thank you very much. This is not working, though. The ExifTool homepage (https://exiftool.org/#supported) as well as the manpages (https://metacpan.org/pod/Image::ExifTool#DESCRIPTION) to Image::ExifTool (v10.40) say that support to MP4 is Read/Write. However,

$exifTool->SetNewValue(Group => 'ItemList', 'albm' => 'My Album');

Fails and returns an error string saying that:
Sorry, Group is not writable

Strangely, the documentation (https://exiftool.org/TagNames/QuickTime.html#ItemList) about QuickTime ItemList tags seems to imply that those tags are writable. But are they? Am I misreading the documentation?

Thanks again.  :)
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: StarGeek on July 13, 2020, 07:41:34 PM
Use the tag name, not the tag ID.  You had the name right the first time.
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: dae65 on July 13, 2020, 07:59:29 PM
Using the tag name instead of the ID fails as well, but now the error string says that:
Tag 'ItemList:Album' is not defined
:-\
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: Phil Harvey on July 13, 2020, 08:00:55 PM
Upgrade your version of ExifTool.

- Phil
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: dae65 on July 13, 2020, 08:10:06 PM
Thanks.
Title: Re: How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?
Post by: dae65 on July 16, 2020, 06:16:40 AM
Just a quick note: I'd like to warn users against a mistake of mine above. This is wrong:

$exifTool->SetNewValue(Group => 'ItemList', Album => 'My Album');

The order of the arguments matters. It should be:

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