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.