Edit all the dates of a MP4 file in one command?

Started by trymeout, April 30, 2021, 05:11:17 PM

Previous topic - Next topic

trymeout



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

StarGeek

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

trymeout

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?

StarGeek

You would have to create a shortcut in an .exiftool_config file.  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.
* 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).

trymeout

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

v16p20

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

Phil Harvey

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

StarGeek

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

trymeout

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"

StarGeek

Those timestamps cannot be removed.  When they're set to 0, that's the removal of the data.
* 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).

trymeout

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?

StarGeek

Add the -api QuickTimeUTC option 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
* 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).

trymeout

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

StarGeek

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

trymeout

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.