News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Micro Video Tags deleted - how to recreate them

Started by Mooe, December 03, 2020, 04:20:26 PM

Previous topic - Next topic

Mooe

Hi Everyone,
Exiftool is a great to reorganize completely a phototec. I have used it to modify dates for a lot of files I had which were disordered.
I think it can be use to solve a problem I have with motion photos.

I have a smartphone which takes micro video embedded in the jpg file (motion photos).
When I upload the photos to Google photo, the website is capable to play the video. I guess everybody know that  :).
I have just discovered that by adding some XMP tags to categorize some photos, I have also erased some important XMP information used by Google photo to recognize embedded micro videos.

On files still having these XMP mandatory information for Google, I have this in XMP :
XMP Toolkit                     : Adobe XMP Core 5.1.0-jc003
Micro Video                     : 1
Micro Video Version             : 1
Micro Video Offset              : 3729773
Micro Video Presentation Timestamp Us: -1


and the Embedded Video Tags as followed
Embedded Video Type             : MotionPhoto_Data
Embedded Video File             : (Binary data 3729717 bytes, use -b option to extract)



On file where I erased the XMP by replacing it with some other tags, I still have some Embedded Video Tags :
Embedded Video Type           : MotionPhoto_Data
Embedded Video File             : (Binary data 3417124 bytes, use -b option to extract)


But I don't have anymore the "MicroVideo" tags (MicroVideo, MicroVideoVersion, MicroVideoOffset, MicroVideoPresentationTimestampUs disappeared).
I have also seen that between "Micro Video Offset" and   "Embedded Video File" the difference is always = 56.

Would someone see a way to recreate the missing XMP data with the remaining "Embedded Video" Tags ?

Thanks

StarGeek

Can you make a sample available?

I don't think the Micro Video, Micro Video Version, and Micro Video Presentation Timestamp Us would be a problem to recreate, as they appear to be simple integers, but the Micro Video Offset might be difficult if it is really needed to find the offset where the video starts.
* 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).

Mooe

Hi StarGeek,
I have attached a sample to my initial post.
I progressed a little bit.
On photo where I lost info, I duplicated them from a file that works well. The offset value is actually the size of the embedded video (so it is quite easy to retrieve it).
Now, I have to redefine this Micro Video Offset value. I know the value of the offset (for my test file, it is = 3417180) but I don't know how to modify it with Exiftool .
I have tried several syntaxes without success :

exiftool -"GCamera:MicroVideoOffset"=3417180 FILE
exiftool -MicroVideoOffset=3417180 FILE

Where I am wrong ?


StarGeek

Exiftool doesn't have any definitions for those tags, so it can't write when it doesn't know how they are supposed to be written.

I threw together this config file which might let you write those tags. I can't guarantee that it's right, but it looked ok when I compared the XMP to the ones in your sample file. Slightly different formatting, but hopefully Google photos can still parse it.

Copy/paste the code into a text file to use as a config or cut the part between the hashtag lines to paste into an existing .exiftool_config file.

%Image::ExifTool::UserDefined = (
#################
'Image::ExifTool::XMP::GCamera' => {
MicroVideo => { Writable => 'integer' },
MicroVideoVersion => { Writable => 'integer' },
MicroVideoOffset => { Writable => 'integer' },
MicroVideoPresentationTimestampUs => { Writable => 'integer' },
},
#################
);
#------------------------------------------------------------------------------
1; #end


I set them to take integers as input, but that can be changed if you see something different.

Here's example output:
C:\>exiftool -config test3.config -P -overwrite_original -MicroVideo=1 -MicroVideoVersion=1 -MicroVideoOffset=3417180 -MicroVideoPresentationTimestampUs=-1 y:\!temp\Test4.jpg
1 image files updated

C:\>exiftool -g1 -a -s -XMP-GCamera:all y:\!temp\Test4.jpg
---- XMP-GCamera ----
MicroVideo                      : 1
MicroVideoOffset                : 3417180
MicroVideoPresentationTimestampUs: -1
MicroVideoVersion               : 1
* 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).

Phil Harvey

@StarGeek, that config file should work fine.  If you use the -api compact=shorthand option when writing, then the format will be exactly the same as the sample, but this shouldn't be necessary.

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

Mooe

@StarGeek, @Phil Harvey, you are genius  ;)
It works perfectly.
I have now to extract all the video offset. Thanks to your example, I think I know how to do.
I have even been able to transform motions photos from an older smartphone (not recognized by Google photo) into motion photos recognized by Google photo.
On the older smartphone, the MicroVideo Tags are not created by the smartphone. So obviously, the website cannot recognize the file.
Let's hope that Google won't change the indentified Tag to something else  :).

Again, a big THANKS for your help.
I have work to do to change all the hundreds of photos I have.

Phil Harvey

If you just need to set MicroVideoOffset to the size of the video in the Samsung trailer, you can do this quickly in batch mode for all files in a directory:

exiftool "-microvideooffset<${embeddedvideofile;$_=length}" DIR

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

Mooe

@Phil,
Thanks, it will be even more efficient but I didn't find the way to make it work.

This TAG has this value :
Embedded Video File             : (Binary data 4080978 bytes, use -b option to extract)

The value of MicroVideoOffset should be the integer from Embedded Video File TAG + 56.
So in the exemple above, at the end, we should have
MicroVideoOffset                : 4081034

Do you see a simple way to do it in 1 or 2 commands ?

Phil Harvey

This should do it:

exiftool "-microvideooffset<${embeddedvideofile;$_=length($_)+56}" DIR

(I initially tried length + 56 but this didn't work because it took the length of "56" instead of the "$_" that is implied if the argument is missing :( )

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

Mooe

#9
Your last proposal works like a charm (after having positionned the config file - this was the missing piece in my first trial).
Thanks again, your expertise and reactivity are really appreciated.