ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: trymeout on April 30, 2021, 05:11:17 PM

Title: Edit all the dates of a MP4 file in one command?
Post by: trymeout on April 30, 2021, 05:11:17 PM


Is it possible to edit all the date and times of a MP4 file with one command? I would like to essentially do these commands all at once instead of six commands if possible.


exiftool "-CreateDate=2018:12:23 00:05:42" test.mp4

exiftool "-ModifyDate=2018:12:23 00:05:42" test.mp4

exiftool "-TrackCreateDate=2018:12:23 00:05:42" test.mp4
exiftool "-TrackModifyDate=2018:12:23 00:05:42" test.mp4

exiftool "-MediaCreateDate=2018:12:23 00:05:42" test.mp4
exiftool "-MediaModifyDate=2018:12:23 00:05:42" test.mp4
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on April 30, 2021, 05:24:03 PM
You can place all the assignments in one command
exiftool "-CreateDate=2018:12:23 00:05:42" "-ModifyDate=2018:12:23 00:05:42" "-TrackCreateDate=2018:12:23 00:05:42" "-TrackModifyDate=2018:12:23 00:05:42" "-MediaCreateDate=2018:12:23 00:05:42" "-MediaModifyDate=2018:12:23 00:05:42" test.mp4

Or you could use a wildcard to combine some of them
exiftool "-CreateDate=2018:12:23 00:05:42" "-ModifyDate=2018:12:23 00:05:42" "-Track*Date=2018:12:23 00:05:42" "-Media*Date=2018:12:23 00:05:42" test.mp4

I wouldn't suggest using something like "-*Date=2018:12:23 00:05:42", you'll fill out more tags than you need.  My quick test showed exiftool would fill 66 tags in a video using that wildcard.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on April 30, 2021, 05:51:26 PM
Is it possible to only have to enter in the date and time once instead of six times? Is there a way to use a variable for the date and time and achieve this all in one command?
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on April 30, 2021, 06:07:49 PM
You would have to create a shortcut in an .exiftool_config file (https://raw.githubusercontent.com/exiftool/exiftool/master/config_files/example.config).  As an example, I have this line in my .exiftool_config file in the shortcut section
VidTime      => ['Quicktime:CreateDate','Quicktime:ModifyDate','Quicktime:TrackCreateDate','Quicktime:TrackModifyDate','Quicktime:MediaCreateDate','Quicktime:MediaModifyDate'],

With this, I would just write -Vidtime="2021:04:28 06:04:34-07:00" and all six tags are written to.

You would replace the shortcut section the example config above with this
%Image::ExifTool::UserDefined::Shortcuts = (
VidTime => ['Quicktime:CreateDate','Quicktime:ModifyDate','Quicktime:TrackCreateDate','Quicktime:TrackModifyDate','Quicktime:MediaCreateDate','Quicktime:MediaModifyDate'],
MyShortcut => ['exif:createdate','exposuretime','aperture'],
MyAlias => 'FocalLengthIn35mmFormat',
);


As for a variable, as long as the value of the variable is passed directly to the command line with the rest of the command, then it would be read by the command.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on April 30, 2021, 08:07:21 PM
In other words there is no easy one line command that can do this with exiftools without any tweaking like this ffmpeg command can? I may stick with ffmpeg for date and time editing but I will keep this exiftool option in mind.

ffmpeg -i "input.mp4" -vcodec copy -acodec copy -metadata creation_time="2010-02-11 12:11:22" "output.mp4"

Thank you for helping me out
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: v16p20 on May 03, 2021, 03:17:43 AM
Quote from: trymeout on April 30, 2021, 05:51:26 PM
Is it possible to only have to enter in the date and time once instead of six times? Is there a way to use a variable for the date and time and achieve this all in one command?

A user variable could also be created for this purpose:

exiftool -userparam "myDate=2010-02-11 12:11:22" "-CreateDate<$myDate" "-ModifyDate<$myDate" FILE
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: Phil Harvey on May 03, 2021, 06:42:26 AM
I would have suggested something like this:

exiftool -time:all="2018:12:23 00:05:42" -wm w FILE

But I may be missing something because I didn't read the whole thread in detail.

- Phil
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 03, 2021, 10:59:59 AM
That's really good.  It won't create new tags and since all the time tags in question in a MP4 will always exist, they will get updated.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 03, 2021, 05:09:56 PM
Quote from: Phil Harvey on May 03, 2021, 06:42:26 AM
I would have suggested something like this:

exiftool -time:all="2018:12:23 00:05:42" -wm w FILE

But I may be missing something because I didn't read the whole thread in detail.

- Phil

This works great! Is there a one line command like this to delete all the date and time metadata from a MP4 file? I tried this command but it justs sets the date and time to 0000:00:00 00:00:00

exiftool -overwrite_original -time:all="" -wm w "file.mp4"
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 03, 2021, 05:24:58 PM
Those timestamps cannot be removed.  When they're set to 0, that's the removal of the data.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 03, 2021, 05:50:50 PM
When I use FFProbe which comes with FFMpeg on Linux, it does not show a date and time field on videos I removed the date and time from. But exiftool will always show a date and time field even if there is no date and time and in that case display the date and time to 0000:00:00 00:00:00?

And is there a way to set the date and time to not be using UTC time but your local time zone. For example if I set the date and time to 2020:01:01 12:00:00 it will actually set it to UTC 2020:01:01 18:00:00 since I am 6 hours behind UTC time. Is there a way to do this so I dont have to always add 6 hours to the time to ensure the date and time is set correctly?
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 03, 2021, 08:44:08 PM
Add the -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC) and exiftool will adjust to UTC based on the time zone included in the data or local computer time zone. 

For example, if I include the timezone when setting the tag
exiftool -api QuickTimeUTC -CreateDate="2021:05:03 12:00:00-05:00" "Y:\!temp\Test1.mp4"
then the embedded time will list as 2021:05:03 17:00:00, adjusted by the five hour difference.

If I drop the -05:00 and use
exiftool -api QuickTimeUTC -CreateDate="2021:05:03 12:00:00"  "Y:\!temp\Test1.mp4"
then the local timezone on my computer will be used.  The result will be 2021:05:03 19:00:00 as my current timezone is -07:00
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 03, 2021, 09:26:18 PM
Is there a way to take this command which sets all the date and time fields using your local computer time in UTC time?

exiftool -time:all="2018:12:23 00:05:42" -wm w FILE
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 03, 2021, 09:34:06 PM
Quote from: StarGeek on May 03, 2021, 08:44:08 PMAdd the -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC)
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 04, 2021, 12:33:01 PM
Thank you

When I use FFProbe which comes with FFMpeg on Linux, it does not show a date and time field on videos if removed the date and time from the videos. But exiftool will always show a date and time field as 0000:00:00 00:00:00 if I did not set a date or time using FFMpeg or Exiftool. Does this mean MP4 files will always have a date and the default date will be 0000:00:00 00:00:00? Or does Exiftool itself always display a date and time and if there is not date and time in the file it will display 0000:00:00 00:00:00?

I also used MediaInfo on a MP4 file with no date and time and MediaInfo did not display any date and time metadata which tells me that exiftool will always display the date and time and if no date and time is present it will display 0000:00:00 00:00:00.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: Phil Harvey on May 05, 2021, 07:27:00 PM
There is always a date/time field in MOV/MP4 videos.  If it is set to zero, it seems that FFMpeg doesn't display it.

- Phil
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 10, 2021, 02:09:18 PM
Quote from: Phil Harvey on May 05, 2021, 07:27:00 PM
There is always a date/time field in MOV/MP4 videos.  If it is set to zero, it seems that FFMpeg doesn't display it.

- Phil

That sucks but it is what it is. Is it a standard for people who do not want a date and time to set the date and time to 0000:00:00 00:00:00 on their MP4 videos to "remove the date and time" for picture and video gallery software to think the MP4 videos have no date set?
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 10, 2021, 03:08:18 PM
Quote from: StarGeek on May 03, 2021, 08:44:08 PM
For example, if I include the timezone when setting the tag
exiftool -api QuickTimeUTC -CreateDate="2021:05:03 12:00:00-05:00" "Y:\!temp\Test1.mp4"
then the embedded time will list as 2021:05:03 17:00:00, adjusted by the five hour difference.

Is there a way to embed the timezone into the date and time and not have the date and time always be set and read in UTC time. For example if I set the date and time to "2021:05:03 12:00:00-05:00" it will be read as "2021:05:03 12:00:00-05:00" by exiftools and other porgrams like MediaInfo and not read as "2021:05:03 17:00:00" in UTC time.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 10, 2021, 04:29:00 PM
Quote from: trymeout on May 10, 2021, 03:08:18 PM
Is there a way to embed the timezone into the date and time and not have the date and time always be set and read in UTC time.

No.

There's no way to add timezone data to the Quicktime integer timestamps like CreateDate, ModifyDate and the various track based timestamps.  They are not a string which would be able to hold a timezone.  The spec says it's supposed to be UTC and most programs will read it as such, though some programs do not properly adjust the time.  Of particular note is that Adobe programs do not adjust from UTC.

If you want exiftool to display the local time, add the -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC) when listing the data.  That option will only affect quicktime tags so it will have no effect on other tags if you include it when reading an image, for example.

Windows will always adjust the time.  Adobe will not.  I can't comment on how MediaInfo will read it. If it doesn't adjust the time like it's supposed to, then you have to decide which program you're using is more important on how it displays the data.  Unfortunately, you can't have it both ways.

Alternatively, you could use the Quicktime:CreationDate and Quicktime:DateTimeOriginal tags.  Those can hold a timezone.  In fact, some programs like Apple Photos require a timezone for those tags otherwise they display junk.  Exiftool ver 12.13 or higher will automatically write the local timezone to those tags if one isn't included.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 10, 2021, 05:19:44 PM
Quote from: StarGeek on May 10, 2021, 04:29:00 PM
Quote from: trymeout on May 10, 2021, 03:08:18 PM
Is there a way to embed the timezone into the date and time and not have the date and time always be set and read in UTC time.

No.

There's no way to add timezone data to the Quicktime integer timestamps like CreateDate, ModifyDate and the various track based timestamps.  They are not a string which would be able to hold a timezone.  The spec says it's supposed to be UTC and most programs will read it as such, though some programs do not properly adjust the time.  Of particular note is that Adobe programs do not adjust from UTC.

If you want exiftool to display the local time, add the -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC) when listing the data.  That option will only affect quicktime tags so it will have no effect on other tags if you include it when reading an image, for example.

Windows will always adjust the time.  Adobe will not.  I can't comment on how MediaInfo will read it. If it doesn't adjust the time like it's supposed to, then you have to decide which program you're using is more important on how it displays the data.  Unfortunately, you can't have it both ways.

Alternatively, you could use the Quicktime:CreationDate and Quicktime:DateTimeOriginal tags.  Those can hold a timezone.  In fact, some programs like Apple Photos require a timezone for those tags otherwise they display junk.  Exiftool ver 12.13 or higher will automatically write the local timezone to those tags if one isn't included.

Is there any date time tags that will not embed a UTC or any timezone like EXIF picture date time tags which are noted saved in UTC time or any time zone and are considered the local time?

And how would you set the Quicktime:CreationDate with a custom timezone embeded?
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: StarGeek on May 10, 2021, 07:00:29 PM
Quote from: trymeout on May 10, 2021, 05:19:44 PM
And how would you set the Quicktime:CreationDate with a custom timezone embeded?

FAQ #5 (https://exiftool.org/faq.html#Q5)
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 11, 2021, 08:24:50 PM
Cool, is there a way to take this command and to have it do exactly this without having to type out the time twice on it? "2020:11:11 12:00:00-0500"

exiftool -overwrite_original -api QuickTimeUTC -time:all="2020:11:11 12:00:00-0500" -wm w -xmp:dateTimeOriginal="2020:11:11 12:00:00-0500" "output.mp4"
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: Phil Harvey on May 11, 2021, 08:53:53 PM
Writing Time:All should also write XMP:DateTimeOriginal.  I don't see why you need that argument at all.

- Phil
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 11, 2021, 09:07:14 PM
When I use the -time:all= command only on this short video it will only write the six date and time tags

Create Date                     : 2020:11:11 17:00:00
Modify Date                     : 2020:11:11 17:00:00
Track Create Date               : 2020:11:11 17:00:00
Track Modify Date               : 2020:11:11 17:00:00
Media Create Date               : 2020:11:11 17:00:00
Media Modify Date               : 2020:11:11 17:00:00

Title: Re: Edit all the dates of a MP4 file in one command?
Post by: Phil Harvey on May 15, 2021, 06:06:33 AM
If you use -wm w then only existing tags will be written.

- Phil
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 19, 2021, 09:15:29 PM
Thank you for all of your help. These are the commands I was able to create to make my life much easier

To delete all date and time metadata from a video file and add the XMP Date/Time Original Metadata
exiftool -overwrite_original -xmp:dateTimeOriginal="2000:01:01 00:00:00" "file.mp4"

To set the date and time with the timezone being saved to the XMP Date/Time Original Metadata if there is a XMP Date/Time Original Metadata field in the video file
exiftool -overwrite_original -api QuickTimeUTC -time:all="2020:12:25 18:11:22-06:00" -wm w "file.mp4"
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: trymeout on May 21, 2021, 12:53:42 PM
I found a better metadata field to set the time without it having to be UTC or even set to any time zone by using the ContentCreateDate tag. The following commands below works for example when you want the video to be set to 2022:11:22 12:00:00 in your local time zone.

Step 1: Delete all date and time fields
exiftool -overwrite_original -time:all= "file.mp4"

Step 2: Add the ContentCreateDate field
exiftool -overwrite_original -ContentCreateDate="2000:01:01 00:00:00" "file.mp4"

Step 3: Set all date and time fields to 2022:11:22 12:00:00 in -06:00
exiftool -overwrite_original -api QuickTimeUTC -time:all="2022:11:22 12:00:00" -wm w "file.mp4"

And this is how it is displayed

$ exiftool "file.mp4"
Create Date                     : 2022:11:22 18:00:00
Modify Date                     : 2022:11:22 18:00:00

Track Create Date               : 2022:11:22 18:00:00
Track Modify Date               : 2022:11:22 18:00:00

Media Create Date               : 2022:11:22 18:00:00
Media Modify Date               : 2022:11:22 18:00:00

Content Create Date             : 2022:11:22 12:00:00


The local time is 12:00 and it will set the UTC time to 18:00.

Is there a way to set the date and time to lets say 12:00:00 but have it in a different time zone like -05:00 without adding "-05:00" to the end of the time in the third command and without having to change the clock on the computer. I personally like how the Content Create Date time is set to 12:00:00 and not 12:00:00-06:00.
Title: Re: Edit all the dates of a MP4 file in one command?
Post by: Phil Harvey on May 28, 2021, 07:42:05 AM
Quote from: trymeout on May 21, 2021, 12:53:42 PM
Is there a way to set the date and time to lets say 12:00:00 but have it in a different time zone like -05:00 without adding "-05:00" to the end of the time in the third command and without having to change the clock on the computer.

How would the time zone then be determined?

- Phil