xmpDM Duration DurationValue & DurationScale for video files

Started by Owen, February 01, 2019, 04:26:29 PM

Previous topic - Next topic

Owen

hi,

apologies if this dealt with elsewhere but my many searches have yielded no joy.

For the life of me I cannot understand how to structure the input to add duration tag info to an XMP file that was created by iMatch as a sidecar file to a large (11GB  1 hour 49 minutes duration) mp4 file.  To avoid confusion I have the exact same problem with small mp4 files.  In all cases, the windows explorer file properties contain apparently accurate "length" information.

I have 3 questions which, if answered, I hope will lead me to the a-ha moment where I understand the subject

Value and Scale
I am able to create and fill the

DurationValue     (eg.  -xmp:DurationValue=1000) and
DurationScale     (eg.  -xmp:DurationScale=600)

tags but if I am being honest, I don't fully understand what these mean exactly.  I have read everything I can find on the subject but I am clearly missing something fundamental!

Question 1
Can someone please tell me what these values should be for a 5 minutes 10 second (310 seconds exactly) duration video file at 25 frames per second and why?  From there I should be able to calculate any others for myself.



Duration
Everything that I try when writing Duration fails with the messages

Warning: Improperly formed sructure for XMP-xmpDM:Duration
Error:  Nothing to write file1.xmp

I have tried integers, floating point numbers, 3 and four pairs of digits separated by colons and semi colons all enclosed in single or double quotes or nothing at all.
Perhaps interestingly, if i use -xmp:Duration=  it succeeds and deletes both DurationValue and DurationScale tags.

Question 2
As before, can someone please give me the input I would use for the same 5 minutes 10 second video file in the first question and briefly explain the reasons why that is the answer.

iMatch 2019
Now the bonus question!
I have searched the iMatch community for answers to the above and following also without solving my problem.
Feel free to disregard this question if you feel it is inappropriately asked in this forum.

Question 3

Does anyone know why iMatch (i think using exiftool to accomplish it) doesn't extract the duration information from the mp4 when it is creating the xmp sidecar file as it does quite readily with other video formats (eg. my raw m2ts files direct from the camera)

Many thanks and great appreciation in advance for any help provided.
regards,
Owen



StarGeek

I can't help with most of this, but I can see the problem with the second question.  Duration is a structured data set  (see Structured Information) and not a single piece of data, so you can't enter it as such. 

If you check the XMP tag names under xmpDM tags, Duration uses the Time Structure, which has two entries, Scale (a rational number) and Value (an integer).

There are a couple of ways to enter this data.  If you add the -struct option, you would add the data this way:
exiftool -struct -Duration="{Scale=0.75,Value=1}"

Exiftool also gives you a way to add the individual pieces separately with the flattened tags.  In this case, the tags are DurationScale and DurationValue.
exiftool -DurationScale =.75 -DurationValue=1

Exiftool will list DurationScale and DurationValue for you separately, but you must remember that they are part of the Duration structure.  I tend to think of structures as if it was data on an index card.  They're always kept together.

Ah, I think I may have found the answer to your first question.  Check 1.2.6.9 in Adobe's XMP SDK Release cc-2016-08/XMPSpecificationPart2.pdf.  Hopefully that link will take you right to the specified location.

edit: changed adobe link to newer version of pdf
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Owen on February 01, 2019, 04:26:29 PM
Does anyone know why iMatch (i think using exiftool to accomplish it) doesn't extract the duration information from the mp4 when it is creating the xmp sidecar file as it does quite readily with other video formats (eg. my raw m2ts files direct from the camera)

Yes, you're correct that iMatch uses exiftool to write metadata.

Looking into this further, I believe the reason is because there isn't a single tag normally available to write it to.  As noted above the Duration tag isn't a single value tag, so exiftool doesn't have a place to put it in the sidecar.  There is the XMP-prm:Duration tag, but exiftool has that marked to avoid writing to by default, as it is part of the PRISM Recipe Metadata 3.0, so duration has a different meaning when it comes to cooking.  TIL that there is a XMP standard for recipes.

The Duration tag in videos such as MP4 files normally comes from the Quicktime tag group. 

In the case of the m2ts video file, can you see where the duration is held in the sidecar? 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Owen

Quote from: StarGeek on February 01, 2019, 06:15:42 PM
In the case of the m2ts video file, can you see where the duration is held in the sidecar?

hi stargeek,

Thanks very much for your prompt reply.  I think that answers the iMatch question.

In answer to your question, I checked this again and I was confused earlier, No the duration info is not extracted from m2ts to the sidecar file.  It is stored in the  M2TS Duration tag which is visible in iMatch.

Which of course raises another question.

Where else is the Duration info stored in an MP4 file?  My mp4 files are created by my video editor (Cyberlink PowerDirector) and do not have the QuickTime tags. (neither MediaHeader or MovieHeader groups).

Actually I just looked at this again, the QT tags are there when the file is relatively small but missing from the large file (both are 01:49:00 duration but one is low res and 1.6GB while the other is Full HD and 12GB).  Maybe I have a large file issue?

Windows can readily see the duration, via File Properties in Windows Explorer, so does it follow that it is available somewhere in a metadata tag?

Hopefully someone can steer me toward an answer.

thanks again for the answer to the iMatch question.
cheers,


StarGeek

Quote from: Owen on February 01, 2019, 09:19:32 PM
Windows can readily see the duration, via File Properties in Windows Explorer, so does it follow that it is available somewhere in a metadata tag?

Video really isn't my thing, so I don't necessarily know too much.  Looking at a vid I have here, I can also see TrackDuration under the various streams.  Otherwise, I'd suggest trying ffprobe from ffmpeg.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Owen

Quote from: StarGeek on February 01, 2019, 05:56:13 PM
Duration is a structured data set  (see Structured Information) and not a single piece of data, so you can't enter it as such. 

There are a couple of ways to enter this data.

hi again Stargeek,

Thanks for your help. 

I have previously been able to successfully write [separately] to the Value and Scale parts of the Duration tag but I don't understand what i am writing.  I do now that I am to use an Integer for Value and a  rational for Scale but what integer and what rational and why?  In the end I want to be able to read duration in an understandable format like HH:MM:SS from a consistent tag for all my video files (mp4, m4a, avi, mov and m2ts) which I think means creating XMP sidecar files.  So writing this info manually to the XMP file may be my only option.

However, notwithstanding the above, I now think my problem lies in the large size of my mp4 files.

I still don't have the answer but I found this topic https://exiftool.org/forum/index.php?topic=3916.0 that you contributed to and by following your advice to add -api largefilesupport=1 to my exiftool command, I am able to "see" the QuickTime tags in the 12GB file.

I guess the question is now, how to copy the Duration from the QuickTime tag in source.mp4 to the xmpDM:Duration tag in the destination.xmp file.
 
Do you have any advice there?

Thanks again for your help so far.

cheers,





StarGeek

I have no knowledge about the Duration other than the link above to the Adobe XMP Spec above.

The only advice I can offer is to ignore the XMP Duration and copy the Quicktime tag into another tag you can easily access or a completely different, unused tag that you repurpose for this case.

For example, you can add it on to the end of Description with something like
exiftool -TagsFromFile %d%f.mp4 "-Description<$Description Duration: $Duration" -ext xmp MyVideo.xmp

Personally, I'm a fan of using HierarchicalSubject for random bits of data like this, especially with iMatch. 
exiftool -TagsFromFile %d%f.mp4 "-HierarchicalSubject+<Duration|$Duration" -ext xmp MyVideo.xmp

Finally, you mentioned that you could see the duration for the m2ts video in iMatch.  Are you saying that you can't see it for the MP4?  Have you tried making sure that iMatch reads and displays the Quicktime tag group?

Go to Edit Menu -> Preferences
Select Metadata 2 Tab (so many freakin' options)
Click the Tag Manager button in the lower right
Look through the various Quicktime entries, there's a bunch of them.  I'd say make sure at least Quicktime MediaHeader and Quicktime MovieHeader are checked.

That may not be enough, though.  Go to your Metadata window and figure out which panel shows the Duration for the m2ts files.  I don't have any so I can't check if it's default or not.  Edit that panel and add the Quicktime Durations tags.  There are a couple of them to choose from, I'm not sure which you might like to use.


"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Owen

Quote from: StarGeek on February 02, 2019, 02:05:39 PM
The only advice I can offer is to ignore the XMP Duration and copy the Quicktime tag into another tag you can easily access or a completely different, unused tag that you repurpose for this case.

I agree.   I think that I will copy the info from the source-file QuickTime Duration Tag to the XMP exif UserComment tag which is consistently available.  Now to work out the syntax!

QuoteFinally, you mentioned that you could see the duration for the m2ts video in iMatch.  Are you saying that you can't see it for the MP4?  Have you tried making sure that iMatch reads and displays the Quicktime tag group?


yes I can see the quicktime tags for all file types.  Except if the file is very large - like the 12GB  file I mention before.  Apologies if I wasn't clear about this but I wasn't aware of this when I wrote my first post.
  I now believe that the problem is restrcted to these large files - regardless of type (mp4, m4v etc)

The problem with that is that most of my finished "product" is very large.  Hence the need (for convenience) to write the formatted Duration info to the XMP file where it is universally available regardless of source-file type or size.

thanks again for your efforts


StarGeek

You might ask on the iMatch forums if it's possible to add the -api largefilesupport=1 for importing data.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Owen

Quote from: StarGeek on February 02, 2019, 06:04:08 PM
You might ask on the iMatch forums if it's possible to add the -api largefilesupport=1 for importing data.

I found the code below in the following topic https://exiftool.org/forum/index.php/topic,3916.0.html and added it to the config file for exiftool in my iMatch folder.  This allowed me to do all that I need to with the Exiftool Command Processor in iMatch.

%Image::ExifTool::UserDefined::Options = (
    LargeFileSupport => 1,
);


I still don't understand the whole Duration/DurationValue/DurationScale topic but I have a solution to my problems.

Thanks again for your help.

Regards,
Owen