Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Samsung GCamera XMP tags #254

Open
doodspav opened this issue Apr 17, 2024 · 9 comments
Open

New Samsung GCamera XMP tags #254

doodspav opened this issue Apr 17, 2024 · 9 comments

Comments

@doodspav
Copy link

doodspav commented Apr 17, 2024

The following tags are used by Samsung's Motion Photo implementation in the App1 XMP:

  • GCamera:MotionPhoto
  • GCamera:MotionPhotoVersion
  • GCamera:MotionPhotoPresentationTimestampUs

The extracted full App1 segment from an image taken on a Samsung Galaxy Z Fold 5 is attached (with a .txt extension because GitHub wouldn't let me upload a .xml file).

Can these tags please be added to exiftool?
Also if it's possible to add the Container as well, but not sure how that would work.

@doodspav
Copy link
Author

%Image::ExifTool::UserDefined = (

    # XMP tags for Samsung's Motion Photo
    'Image::ExifTool::XMP::GCamera' => {
        MotionPhoto =>                        { Writable => 'integer' },
        MotionPhotoVersion =>                 { Writable => 'integer' },
        MotionPhotoPresentationTimestampUs => { Writable => 'integer' },
    },

);

1;  # end

This is what I have right now in my config file, and it works.

@StarGeekSpaceNerd
Copy link
Collaborator

Any idea how it comes up with the MotionPhotoPresentationTimestampUs? The value of 2590122 isn't a date or time, nor is it a Unix time stamp.

The three you list should be easy enough to make a config file (and… you've gone and done it while I'm typing :D )

The XMP-Container:Directory is a bit more complex as it is a structured tag and a list type tag.

@doodspav
Copy link
Author

doodspav commented Apr 17, 2024

The MotionPhotoPresentationTimestampUs seems to be the time offset of the key frame image from the start of the video.

@doodspav
Copy link
Author

doodspav commented Apr 17, 2024

If XMP-Container::Directory is a structured tag and a list type tag, what type are the other tags I've mentioned so far? Also I read somewhere that if you write a list type tag twice, it writes the value twice rather than replacing the old one. So how would I replace the old value?

Also let me know if you manage to write the config definition for the XMP-Container::Directory because I could really use it for completeness in my project. All I can find so far is a commented out thing with a note about it conflicting with Google's depth-map Device tags.

@boardhead
Copy link
Contributor

Thanks. I'll add these to the next release. The "Us" in the timestamp tag name is likely microseconds.

If you want to replace the old value of a list tag, just write it once. If you write it twice, you replace the old value with two new values.

I had already generated the necessary code for the Container tags, but I won't impement it due to a conflict with other Google tags. See here:

https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/XMP2.pl#L2108

  • Phil

@doodspav
Copy link
Author

doodspav commented Apr 18, 2024

So if I put this into my config file:

    'Image::ExifTool::XMP::Container' => {
        %xmpTableDefaults,
        GROUPS => { 1 => 'XMP-Container', 2 => 'Image' },
        NAMESPACE => 'Container',
        NOTES => 'Google Container namespace.',
        Directory => {
            Name => 'ContainerDirectory',
            FlatName => 'Directory',
            List => 'Seq',
            Struct => {
                STRUCT_NAME => 'Directory',
                Item => {
                    Namespace => 'Container',
                    Struct => {
                        STRUCT_NAME => 'Item',
                        NAMESPACE => { Item => 'http://ns.google.com/photos/1.0/container/item/'},
                        Mime     => { Writable => 'string'  },
                        Semantic => { Writable => 'string'  },
                        Length   => { Writable => 'integer' },
                        Label    => { },
                        Padding  => { Writable => 'integer' },
                        URI      => { },
                    },
                },
            },
        },
    },

How do I set values for this via the command line?

Also, I'm just assuming that it's correct. Idk if I can do %xmpTableDefaults in a config file, but nothing complained about that so far.

@boardhead
Copy link
Contributor

This won't work for a few reasons, but the biggest problem is a conflict with a different Google Container schema.

I don't have time right now to figure out how this could be done. Maybe sometime in the next week or so I can try this.

  • Phil

@StarGeekSpaceNerd
Copy link
Collaborator

See the Structured Information page for dealing with structured data.

Structured data is very complex to deal with. Exiftool can flatten the individual tags within the structure and treat them like a list type tag, but this has problems when one of the structures is missing data that the others don't have. With a correct config file, the flattened output from your App1 xmp data above would look something like this

[XMP-Container] DirectoryItemMime               : image/jpeg,video/mp4
[XMP-Container] DirectoryItemSemantic           : Primary,MotionPhoto
[XMP-Container] DirectoryItemLength             : 0,4370106
[XMP-Container] DirectoryItemPadding            : 138,4370106

Adding the -struct option shows you the actual format of the Directory tag.

C:\>exiftool -G1 -a -s -e --file:all -struct -Directory Y:\!temp\x\y\app1.xmp
[XMP-Container] Directory                       : [{Item={Length=0,Mime=image/jpeg,Padding=138,Semantic=Primary}},{Item={Length=4370106,Mime=video/mp4,Padding=0,Semantic=MotionPhoto}}]

or in a more human readable form

[{
        Item = {
            Length = 0,
            Mime = image / jpeg,
            Padding = 138,
            Semantic = Primary
        }
    }, {
        Item = {
            Length = 4370106,
            Mime = video / mp4,
            Padding = 0,
            Semantic = MotionPhoto
        }
    }
]

So with a proper config file, you could either write the data as flattened tags (note that these may not be the actual names with a config file)

exiftool -XMP-Container:DirectoryItemMime="image/jpeg,video/mp4" -XMP-Container:DirectoryItemSemantic="Primary,MotionPhoto" -XMP-Container:DirectoryItemLength="0,4370106" -XMP-Container:DirectoryItemPadding="138,0" /path/to/files/

or when using the -struct option

exiftool -XMP-Container:Directory=[{Item={Length=0,Mime=image/jpeg,Padding=138,Semantic=Primary}},{Item={Length=4370106,Mime=video/mp4,Padding=0,Semantic=MotionPhoto}}] /path/to/files/

@doodspav
Copy link
Author

Wow yeah that does look complicated. I tried the config file, and you're right that it doesn't work out of the gate, but I'm stumped as to what to do to fix it / how to resolve the conflict.

For now I'll just skip the container when making my motion photos, and if Phil manages to come up with a solution, I'll incorporate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants