How can I use Image::ExifTool to set QuickTime instead of XMP tags in MP4 files?

Started by dae65, July 13, 2020, 04:58:27 PM

Previous topic - Next topic

dae65

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:


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

StarGeek

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

dae65

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,

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

Fails and returns an error string saying that:
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

Use the tag name, not the tag ID.  You had the name right the first time.
* 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).

dae65

Using the tag name instead of the ID fails as well, but now the error string says that:
Tag 'ItemList:Album' is not defined
:-\

Phil Harvey

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


dae65

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.