Main Menu

Add XMP tag to MP4 Files

Started by rezadu, July 02, 2024, 10:24:46 PM

Previous topic - Next topic

rezadu

I am seeing an issue after I run exiftool to organize my photos/videos where timeline view in Synology gets out of order only for video files. I think its a bug with Synology and would like help with a work around to add an XMP tag to MP4 files. Here is what I have found out....

Synology Photos sorts videos from the following metadata as described here.
Videos - XMP information:Quicktime videos (higher priority): Xmp.xmp.com.apple.quicktime.creationdate
All videos: Xmp.video.DateUTC (In UTC "%Year:%Month:%Date:%Time" format)

After much troubleshooting, this metadata does not exist on my videos taken from Android phones. My phone a Google Pixel 8 Pro nor my wifes Samsung s21 contain the following tags on videos that synology sorts with,  Xmp.xmp.com.apple.quicktime.creationdate or Xmp.video.DateUTC. What I have found is that videos taken from iPhones do contain this tag and I have no issues with my workflow with photos/videos from iPhones.

I use Exiftool to automate and organize my files, and in that process the file is modified. Here is an example command that I run:
exiftool -m -r -i "@eaDir" -F -o "/volume1/photo/dummy" -d "/volume1/photo/%Y/%m/%Y%m%d-%H%M%S-%%f%%-c.%%e" "-filename<createdate" "-filename<datetimeoriginal" "-filename<filemodifydate" "/volume1/photo/unsorted/"
Since synology sorts photo files using exif metadata (which exists on my photo files) my photos show the correct date/time in the timeline, however all my videos show a date when the exiftool was ran since there was no xmp metadata to sort on and falls back to filemodification date.

I have talked with Synology support but they say this works as designed and to open a feature request. They will not treat this as a bug.

Here are some examples using exiftool and exiv2 that Synology support used to troubleshoot:

My android video file:
$ exiftool PXL_20240112_224754035.mp4
ExifTool Version Number         : 12.67
File Name                       : PXL_20240112_224754035.mp4
Directory                       : .
File Size                       : 114 MB
File Modification Date/Time     : 2024:01:12 16:48:14-06:00
File Access Date/Time           : 2024:07:02 14:55:41-05:00
File Inode Change Date/Time     : 2024:07:02 14:55:41-05:00
File Permissions                : -rwxrwxrwx
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4 Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 2.0.0
Compatible Brands               : isom, iso2, mp41
Media Data Size                 : 113538595
Media Data Offset               : 44
Movie Header Version            : 0
Create Date                     : 2024:01:12 22:48:14
Modify Date                     : 2024:01:12 22:48:14
Time Scale                      : 10000
Duration                        : 18.93 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 4
GPS Coordinates                 : 29 deg 18' 47.16" N, 94 deg 47' 27.96" W
Android Manufacturer            : Google
Android Model                   : Pixel 8 Pro
Android Capture Fps             : 30
Track Header Version            : 0
Track Create Date               : 2024:01:12 22:48:14
Track Modify Date               : 2024:01:12 22:48:14
Track ID                        : 1
Track Duration                  : 18.93 s
Track Layer                     : 0
Track Volume                    : 0.00%
Meta Format                     : mett
Meta Type                       : application/meta
Warning                         : [minor] The ExtractEmbedded option may find more tags in the media data
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 48000
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Image Width                     : 3840
Image Height                    : 2160
Media Header Version            : 0
Media Create Date               : 2024:01:12 22:48:14
Media Modify Date               : 2024:01:12 22:48:14
Media Time Scale                : 90000
Media Duration                  : 18.93 s
Handler Type                    : Video Track
Handler Description             : VideoHandle
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 3840
Source Image Height             : 2160
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Pixel Aspect Ratio              : 65536:65536
Color Profiles                  : nclx
Color Primaries                 : BT.709
Transfer Characteristics        : BT.709
Matrix Coefficients             : BT.709
Video Frame Rate                : 30.003
Image Size                      : 3840x2160
Megapixels                      : 8.3
Avg Bitrate                     : 48 Mbps
GPS Latitude                    : 29 deg 18' 47.16" N
GPS Longitude                   : 94 deg 47' 27.96" W
Rotation                        : 0
GPS Position                    : 29 deg 18' 47.16" N, 94 deg 47' 27.96" W

$ /var/packages/SynologyPhotos/target/usr/bin/exiv2 -pa /volume1/photo/zzzxmptest/PXL_20240112_224754035.mp4
Xmp.video.FileSize                           XmpText     7  108.295
Xmp.video.FileName                           XmpText    52  /volume1/photo/zzzxmptest/PXL_20240112_224754035.mp4
Xmp.video.MimeType                           XmpText    15  video/quicktime
Xmp.video.MajorBrand                         XmpText    37  MP4 Base Media v1 [IS0 14496-12:2003]
Xmp.video.MinorVersion                       XmpText     6  131072
Xmp.video.CompatibleBrands                   XmpSeq      3  MP4 Base Media v1 [IS0 14496-12:2003], MP4 Base Media v2 [ISO 14496-12:2005], MP4 v1 [ISO 14496-1:ch13]
Xmp.video.AspectRatio                        XmpText     3  1:1

Video File taken from iPhone:
$ exiftool IMG_S_0938.MOV
ExifTool Version Number         : 12.67
File Name                       : IMG_S_0938.MOV
Directory                       : .
File Size                       : 3.6 MB
File Modification Date/Time     : 2024:02:18 15:20:26-06:00
File Access Date/Time           : 2024:07:02 21:18:51-05:00
File Inode Change Date/Time     : 2024:07:02 21:18:51-05:00
File Permissions                : -rwxrwxrwx
File Type                       : MOV
File Type Extension             : mov
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Media Data Size                 : 3555187
Media Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2023:02:18 01:29:39
Modify Date                     : 2023:02:18 01:29:43
Time Scale                      : 600
Duration                        : 3.50 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 6
Track Header Version            : 0
Track Create Date               : 2023:02:18 01:29:39
Track Modify Date               : 2023:02:18 01:29:43
Track ID                        : 1
Track Duration                  : 3.50 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1080
Clean Aperture Dimensions       : 1920x1080
Production Aperture Dimensions  : 1920x1080
Encoded Pixels Dimensions       : 1920x1080
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : hvc1
Source Image Width              : 1920
Source Image Height             : 1080
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : HEVC
Bit Depth                       : 24
Video Frame Rate                : 29.971
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Purchase File Format            : mp4a
Warning                         : [minor] The ExtractEmbedded option may find more tags in the media data
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Content Describes               : Track 1
Media Header Version            : 0
Media Create Date               : 2023:02:18 01:29:39
Media Modify Date               : 2023:02:18 01:29:43
Media Time Scale                : 600
Media Duration                  : 3.50 s
Media Language Code             : und
Gen Media Version               : 0
Gen Flags                       : 0 0 0
Gen Graphics Mode               : ditherCopy
Gen Op Color                    : 32768 32768 32768
Gen Balance                     : 0
Handler Class                   : Data Handler
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Meta Format                     : mebx
Handler Type                    : Metadata Tags
Make                            : Apple
Model                           : iPhone 11
Software                        : 16.1.1
Creation Date                   : 2023:02:17 19:29:39-06:00
Image Size                      : 1920x1080
Megapixels                      : 2.1
Avg Bitrate                     : 8.12 Mbps
Rotation                        : 0

$ /var/packages/SynologyPhotos/target/usr/bin/exiv2 -pa /volume1/photo/zzzxmptest/IMG_S_0938.MOV
Xmp.video.FileSize                           XmpText     7  3.39936
Xmp.video.FileName                           XmpText    40  /volume1/photo/zzzxmptest/IMG_S_0938.MOV
Xmp.video.MimeType                           XmpText    15  video/quicktime
Xmp.video.MajorBrand                         XmpText    25  Apple QuickTime (.MOV/QT)
Xmp.video.MinorVersion                       XmpText     1  0
Xmp.video.CompatibleBrands                   XmpSeq      1  Apple QuickTime (.MOV/QT)
Xmp.video.MovieHeaderVersion                 XmpText     1  0
Xmp.video.DateUTC                            XmpText    10  3759528579
Xmp.video.ModificationDate                   XmpText    10  3759528583
Xmp.video.TimeScale                          XmpText     3  600
Xmp.video.Duration                           XmpText     4  3503
Xmp.video.PreferredRate                      XmpText     1  1
Xmp.video.PreferredVolume                    XmpText     3  100
Xmp.video.PreviewTime                        XmpText     1  0
Xmp.video.PreviewDuration                    XmpText     1  0
Xmp.video.PosterTime                         XmpText     1  0
Xmp.video.SelectionTime                      XmpText     1  0
Xmp.video.SelectionDuration                  XmpText     1  0
Xmp.video.CurrentTime                        XmpText     1  0
Xmp.video.NextTrackID                        XmpText     1  6
Xmp.video.TrackHeaderVersion                 XmpText     1  0
Xmp.video.TrackCreateDate                    XmpText    10  3759528579
Xmp.video.TrackModifyDate                    XmpText    10  3759528583
Xmp.video.TrackID                            XmpText     1  1
Xmp.video.TrackDuration                      XmpText     1  3
Xmp.video.TrackLayer                         XmpText     1  0
Xmp.video.TrackVolume                        XmpText     3  100
Xmp.video.Width                              XmpText     4  1920
Xmp.video.Height                             XmpText     4  1080
Xmp.video.CleanApertureWidth                 XmpText     6  1920.0
Xmp.video.CleanApertureHeight                XmpText     6  1080.0
Xmp.video.ProductionApertureWidth            XmpText     6  1920.0
Xmp.video.ProductionApertureHeight           XmpText     6  1080.0
Xmp.video.EncodedPixelsWidth                 XmpText     6  1920.0
Xmp.video.EncodedPixelsHeight                XmpText     6  1080.0
Xmp.video.MediaHeaderVersion                 XmpText     1  0
Xmp.video.MediaCreateDate                    XmpText    10  3759528579
Xmp.video.MediaModifyDate                    XmpText    10  3759528583
Xmp.video.MediaTimeScale                     XmpText     3  600
Xmp.video.MediaDuration                      XmpText     1  3
Xmp.video.MediaLangCode                      XmpText     5  21956
Xmp.video.HandlerClass                       XmpText    12  Data Handler
Xmp.video.HandlerType                        XmpText    10  Alias Data
Xmp.video.HandlerVendorID                    XmpText     5  Apple
Xmp.video.GraphicsMode                       XmpText    10  ditherCopy
Xmp.video.OpColor                            XmpText     5  32768
Xmp.video.Codec                              XmpText     4  hvc1
Xmp.video.SourceImageWidth                   XmpText     4  1920
Xmp.video.SourceImageHeight                  XmpText     4  1080
Xmp.video.XResolution                        XmpText     2  72
Xmp.video.YResolution                        XmpText     2  72
Xmp.video.Compressor                         XmpText     4  HEVC
Xmp.video.BitDepth                           XmpText     2  24
Xmp.video.FrameRate                          XmpText     7  29.9715
Xmp.audio.TrackHeaderVersion                 XmpText     1  0
Xmp.audio.TrackCreateDate                    XmpText    10  3759528579
Xmp.audio.TrackModifyDate                    XmpText    10  3759528583
Xmp.audio.TrackID                            XmpText     1  2
Xmp.audio.TrackDuration                      XmpText     1  3
Xmp.audio.TrackLayer                         XmpText     1  0
Xmp.audio.MediaHeaderVersion                 XmpText     1  0
Xmp.audio.MediaCreateDate                    XmpText    10  3759528579
Xmp.audio.MediaModifyDate                    XmpText    10  3759528583
Xmp.audio.MediaTimeScale                     XmpText     5  44100
Xmp.audio.MediaDuration                      XmpText     1  3
Xmp.audio.MediaLangCode                      XmpText     5  21956
Xmp.audio.HandlerClass                       XmpText    12  Data Handler
Xmp.audio.HandlerType                        XmpText    10  Alias Data
Xmp.audio.HandlerVendorID                    XmpText     5  Apple
Xmp.audio.Balance                            XmpText     1  0
Xmp.audio.Compressor                         XmpText     4  mp4a
Xmp.audio.ChannelType                        XmpText     1  2
Xmp.audio.BitsPerSample                      XmpText     2  16
Xmp.audio.SampleRate                         XmpText     5  44100
Xmp.xmp.com.apple.quicktime.make             XmpText     5  Apple
Xmp.xmp.com.apple.quicktime.model            XmpText     9  iPhone 11
Xmp.xmp.com.apple.quicktime.software         XmpText     6  16.1.1
Xmp.xmp.com.apple.quicktime.creationdate     XmpText    24  2023-02-17T19:29:39-0600
Xmp.video.AspectRatio                        XmpText     4  16:9

I am looking for a way to add the Xmp.video.DateUTC metadata to my video files as a workaround. Is there a way to do this with exiftool or exiv2?

Phil Harvey

ExifTool can add any XMP to MOV/MP4 videos.  I don't know what Xmp.video.DateUTC is, but if it isn't one of the pre-defined XMP tags then you can create a user-defined XMP tag.

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

rezadu

Xmp.video.DateUTC is seen above in the iPhone metadata dump specifically when run against exiv2

$ /var/packages/SynologyPhotos/target/usr/bin/exiv2 -pa /volume1/photo/zzzxmptest/IMG_S_0938.MOV
Xmp.video.FileSize                           XmpText     7  3.39936
Xmp.video.FileName                           XmpText    40  /volume1/photo/zzzxmptest/IMG_S_0938.MOV
Xmp.video.MimeType                           XmpText    15  video/quicktime
Xmp.video.MajorBrand                         XmpText    25  Apple QuickTime (.MOV/QT)
Xmp.video.MinorVersion                       XmpText     1  0
Xmp.video.CompatibleBrands                   XmpSeq      1  Apple QuickTime (.MOV/QT)
Xmp.video.MovieHeaderVersion                 XmpText     1  0
Xmp.video.DateUTC                            XmpText    10  3759528579  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Xmp.video.ModificationDate                   XmpText    10  3759528583
Xmp.video.TimeScale                          XmpText     3  600

I'll look into user defined tags as it appears it is not pre-defined.
$ exiftool -XMP:video:DateUTC="2023-07-03T12:34:56Z" -overwrite_original PXL_20240112_224754035.mp4
Warning: Tag 'XMP:video:DateUTC' is not defined
Nothing to do.

StarGeek

#3
Quote from: Phil Harvey on July 03, 2024, 06:30:38 AMI don't know what Xmp.video.DateUTC is, but if it isn't one of the pre-defined XMP tags then you can create a user-defined XMP tag.

There is a very (very) long list of XMP-video/XMP-audio tags that exiv2 writes that are used in DigiKam (I think). Around 300 of them. I started creating a config file for these, but it is a large task, made more difficult by the face that exiv2 doesn't seem to do any sanity checks on the data it writes.  It will also create arbitrary tags, i.e. if you want to write to XMP-GooglyEyes, it will do so.

Some of the tags are listed as "Closed Choice of text/Integer/other data types" but because of the lack of checks on the data, it isn't easy to figure out what the "Closed Choice" values are supposed to be.

Checking my files, I think this config file is in "working" condition. But almost all the tags are set as simple strings, so some of them may not write the data correctly, as I have nothing to check against.

I'll double-check to see if it works and try to get it up in a day or two. I seem to have lost the links for the sources I used and want to dig those up.

Edit: This is the thread that got me started on the config file. And the eviv2 source code which lists the XMP-video tags and the XMP-audio tags.
* 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).

StarGeek

I've posted my "working" config file here. There are almost certainly some broken tags, as I couldn't find a sample 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).