Write Live Photo metadata to video using FFMPEG
Asked Answered
K

1

6

According to Apple Live Photo file format, there are three pieces of metadata that need to be written for a JPEG and MOV to be accepted as a live photo. I can use exiftool and ffmpeg to write the necessary content identifier metadata.

For the JPEG:

exiftool -TagsFromFile reference.jpeg -makernotes -ContentIdentifier image.jpeg
exiftool -ContentIdentifier="$id" image.jpeg

Similarly, ffmpeg can be used to write the top-level Quicktime metadata with matching id.

However I'm having trouble with the timed metadata: ["com.apple.quicktime.still-image-time" : 0xFF].

I can't even manage to produce a copy of an existing live photo MOV file using ffmpeg that preserves the necessary timed metadata.

ffmpeg -i original.mov -map 0 -c copy -movflags use_metadata_tags copy.mov

copies the global metadata (i.e. com.apple.quicktime.content.identifier), but loses the necessary still-image-time which can be confirmed using exiftool:

> exiftool -G -U -ee original.mov | grep 'Still Image Time'
[QuickTime]     Still Image Time                : -1
> exiftool -G -U -ee copy.mov | grep 'Still Image Time'
> 

How can I write the timed metadata using ffmpeg—specifically the still-image-time data?

Edit: it looks like this may be happening because ffmpeg does not know how to handle the mebx tag on data streams:

[mov @ 0x7fb232091400] Unknown hldr_type for mebx, writing dummy values

And ffmpeg doesn't seem to have a way to copy unknown streams. This appears to also be a problem for dealing with the fdsc tag in GoPro metadata streams (e.g. see https://gist.github.com/radimklaska/8974637522a751adb49db0de3be482c9#file-gopro_hevc_to_dnxhd-sh-L125), so it's often copied over as gpmd data, which ensures it's not overwritten with dummy values, but this trick doesn't work in the case of live photos mebx metadata.

Kemeny answered 20/12, 2020 at 3:3 Comment(1)
Hi, I faced the same problem, did you figure this out so far?Bush
R
2

I have the same question, and I think it should be possible with the bento4 tools. I've previously used this to copy the GPS metadata which is also stored in this structure, it should work in this case as well, however I don't know enough about it to get it to work.

It seems the mebx data is stored in moov/trak/mdia/minf/stbl/stsd, however I cannot get this transplanted properly.

E.g. this does not work and creates a big broken file:

# Get atom from original file
mp4extract moov/trak IMG_1337.MOV trak.atom

# insert into converted file
mp4edit --insert moov:trak.atom IMG_1337-converted.MOV IMG_1337-converted-metadata.MOV

Hope somebody can build on this.

Rosenkranz answered 5/8, 2021 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.