英文:
EXIFTOOL: copy and concatenate QUICKTIME-, XML- and XMP-tags
问题
I'm using EXIFTOOL-version 12.57 and I want to write metatags to MP4-files, but do not manage to copy and concatenate values from existing (group)tags and a text-string.
To create a [XMP]:Copyright-tag I want to copy the year of the [QUICKTIME]:CreateDate-Tag and add some copyright-text.
exiftool -d %Y -xmp:Copyright<quicktime:CreateDate target.MP4
stores the year (YYYY) of [QUICKTIME]:CreateDate to [XMP]:Copyright in the target.MP4-file. If [XMP]:Copyright does not exist it is created.
I want to add (existing) [XMP]:Author and some text to get a [XMP]:Copyright-tag like this:
®YYYY by [XMP]:Author. All rights reserved.
How do I concatenate [QUICKTIME]:CreateDate, [XMP]:Author and some text and write it to the [XMP]:Copyright-tag?
英文:
I'm using EXIFTOOL-version 12.57 and I want to write metatags to MP4-files, but do not manage to copy and concatenate values from existing (group)tags and a text-string.
To create a [XMP]:Copyright-tag I want to copy the year of the [QUICKTIME]:CreateDate-Tag and add some copyright-text.
exiftool -d %Y -xmp:Copyright<quicktime:CreateDate target.MP4
stores the year (YYYY) of [QUICKTIME]:CreateDate to [XMP]:Copyright in the target.MP4-file. If [XMP]:Copyright does not exist it is created.
I want to add (existing) [XMP]:Author and some text to get a [XMP]:Copyright-tag like this:
®YYYY by [XMP]:Author. All rights reserved.
How do I concatenate [QUICKTIME]:CreateDate, [XMP]:Author and some text and write it to the [XMP]:Copyright-tag?
Have a nice day.
答案1
得分: 0
从关于-TagsFromFile
选项的文档中:
重定向功能的扩展允许在<符号的右侧使用涉及标记名称的字符串,语法为""'-DSTTAG<STR'"",其中STR中的标记名称前缀为$符号。有关此语法的更多详细信息,请参阅-p选项和"高级格式特性"部分。
因此,标记复制操作将是:
"-xmp:Copyright<©$quicktime:CreateDate by ${XMP:Author}. All rights reserved."
由于标记名称后面紧随点号,因此在XMP:Author
周围使用大括号。关于需要使用大括号的详细信息在-p
(-printFormat
)选项下有详细说明。
需要注意几点。您没有提到正在使用的操作系统和shell。上面的命令适用于Windows CMD。在Mac/Linux下,双引号内的美元符号具有特殊含义,因此需要将双引号更改为单引号。Windows Powershell可能也适用相同的规则,但我不确定。
其次,您问题中的示例命令没有在包含<
符号的部分周围加上引号。否则,shell会将<
解释为文件重定向,而不会传递给exiftool。
另外,有一个边际情况,可能会导致年份不正确。Quicktime时间戳应该是UTC时间。在新年前夕/新年之间的时区差异可能会导致年份发生变化。例如,2022年12月31日20:00:00-05:00 EST拍摄的视频将在文件中变为2023年01月01日01:00:00(UTC时间1点),导致版权为©2023,而不是©2022。可以在命令中添加-api QuickTimeUTC
选项,exiftool将调整时间为本地时间,从而得到正确的年份。
英文:
From the docs on the -TagsFromFile
option
>An extension of the redirection feature allows strings involving tag names to be used on the right hand side of the < symbol with the syntax "'-DSTTAG<STR'", where tag names in STR are prefixed with a $ symbol. See the -p option and the "Advanced formatting feature" section for more details about this syntax.
So the tag copy operation would be
"-xmp:Copyright<©$quicktime:CreateDate by ${XMP:Author}. All rights reserved."
Braces are used around XMP:Author
due to the dot following directly behind the tag name. The details on needing the use of braces is detailed under the -p
(-printFormat
) option.
There are a few things to take note of. You do not mention the OS and shell you're using. The above command is for Windows CMD. Under Mac/Linux, the dollar sign has special meaning inside of double quotes, so the double quotes need to be changed into single quotes. The same probably applies to Windows Powershell, but I'm not sure.
Second, the example command in your question does not have quotes around the part of the command with the <
symbol. Quotes are required otherwise the shell will interpret the <
as file redirection and it will not get passed to exiftool.
Additionally, there is an edge case where the year may be incorrect. Quicktime timestamps are supposed to be in UTC. A time zone difference around New Years Eve/Day might change the year. For example, a video shot at 2022:12:31 20:00:00-05:00 EST would be end up as 2023:01:01 01:00:00 (1 am UTC) in the file, resulting in a copyright of ©2023 instead of ©2022. The -api QuickTimeUTC
option can be added to the command and exiftool will adjust the time to local time, giving the correct year.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论