Delete Date tags if set as "0000:00:00 00:00:00"

Started by vicmarto, August 29, 2019, 10:53:23 AM

Previous topic - Next topic

Phil Harvey

Quote from: kennethmac2000 on July 17, 2021, 08:32:43 AM
Quote from: Phil Harvey on August 29, 2019, 11:31:27 AM
'-createdate<${createdate;$_ = undef if /^0000/}'

As far as I can tell, this only works if the API option QuickTimeUTC is not set, as otherwise a binary zero value gets converted to 1904-01-01 00:00:00. One could match on /^1904/ in that case, but that feels rather less elegant.

This is perfectly elegant, and handles both cases:

'-createdate<${createdate;$_ = undef if /^(0000|1904)/}'

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

kennethmac2000

Quote from: Phil Harvey on July 18, 2021, 06:24:39 AM
Quote from: kennethmac2000 on July 17, 2021, 08:32:43 AM
Quote from: Phil Harvey on August 29, 2019, 11:31:27 AM
'-createdate<${createdate;$_ = undef if /^0000/}'

As far as I can tell, this only works if the API option QuickTimeUTC is not set, as otherwise a binary zero value gets converted to 1904-01-01 00:00:00. One could match on /^1904/ in that case, but that feels rather less elegant.

This is perfectly elegant, and handles both cases:

'-createdate<${createdate;$_ = undef if /^(0000|1904)/}'

- Phil

I get that I could do that. However, as a bit of an exercise/challenge, I would now like to understand how I could run exiftool once, store the result in some sort of intermediate 'scratch' file, and then run exiftool a second time with that scratch file as input (as described in my previous post).

That said, and as an aside, have you thought of allowing people to interact with the raw binary values of tags? (I know you can see them using the -v3 tag, but actually reference them in an -if for example.)

StarGeek

Quote from: kennethmac2000 on July 18, 2021, 09:17:46 AM
I get that I could do that. However, as a bit of an exercise/challenge, I would now like to understand how I could run exiftool once, store the result in some sort of intermediate 'scratch' file, and then run exiftool a second time with that scratch file as input (as described in my previous post).

You could use the -efile option.

QuoteThat said, and as an aside, have you thought of allowing people to interact with the raw binary values of tags? (I know you can see them using the -v3 tag, but actually reference them in an -if for example.)

You do with the -n (--printConv) option or its # shortcut.  The -api QuickTimeUTC option overrides that.  See details in that link.
* 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).

kennethmac2000

Quote from: StarGeek on July 18, 2021, 10:53:13 AM
You could use the -efile option.

Thanks. I'll try that.

Quote from: StarGeek on July 18, 2021, 10:53:13 AM
You do with the -n (--printConv) option or its # shortcut.  The -api QuickTimeUTC option overrides that.  See details in that link.

That doesn't seem to work for date/time values - they still appear formatted. I saw this being discussed on another thread on this forum, where it was noted that you could see the raw values with -v3, but you couldn't actually 'get hold of' them to do anything with.

kennethmac2000

Quote from: Phil Harvey on July 18, 2021, 06:24:39 AM
This is perfectly elegant, and handles both cases:

'-createdate<${createdate;$_ = undef if /^(0000|1904)/}'

- Phil

Checking for 1904 doesn't differentiate between the scenario where -api QuickTimeUTC has interpreted 0 as 1904-01-01T00:00:00+00:00 and the scenario where 1904-01-01T00:00:00+00:00 has actually been set explicitly. Could those be different (binary) values?

Interestingly, if f I run 'exiftool -api QuickTimeUTC -QuickTime:CreateDate mymovie.mp4, I get the following output:
Create Date                     : 1904:01:01 00:00:00+00:00

If I then run exiftool -api QuickTimeUTC -QuickTime:CreateDate='1904:01:01 00:00:00+00:00' mymovie.mp4 (ie, literally copying the value output by the command above), and then run 'exiftool -api QuickTimeUTC -QuickTime:CreateDate mymovie.mp4 again, I get the following output:
Create Date                     : 2004:01:01 00:00:00+00:00

If I check the value of QuickTime:CreateDate by running exiftool -v3 mymovie.mp4, I see it now has the value bc 19 13 80, whereas prior to running the above update command it had the value 00 00 00 00. Is it possible to actually get it back to 00 00 00 00?

StarGeek

#20
Quote from: kennethmac2000 on July 18, 2021, 01:57:23 PM
Checking for 1904 doesn't differentiate between the scenario where -api QuickTimeUTC has interpreted 0 as 1904-01-01T00:00:00+00:00 and the scenario where 1904-01-01T00:00:00+00:00 has actually been set explicitly. Could those be different (binary) values?

Phil will have to comment on the specifics, but it might be that the spec doesn't allow for timestamps earlier than 1970:01:01 00:00:01.  At least that's the earliest I can set it without problems.

Edit: The date is held as an unsigned 32 bit integer (see QuickTime MovieHeader Tags, so it probably can't be set before the start of epoch time.  Still just a guess on my part.

QuoteIs it possible to actually get it back to 00 00 00 00?

Delete the tag with
exiftool -QuickTime:CreateDate= mymovie.mp4

The tag itself cannot be completely removed and will still show 0s, but that's the equivalent to deleting it.
* 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).

Phil Harvey

The QuickTime epoch is 1904, but ExifTool has problems with dates before 1970 because it uses the standard C date/time library functions which have an epoch of 1970.

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