doodspav / motionphoto

Python library for creating Google and Samsung compatible Motion Photos.
Apache License 2.0
7 stars 0 forks source link

Attempt to parse key-frame timestamp from Live Photo #3

Open doodspav opened 4 months ago

doodspav commented 4 months ago

Discussed here. Add when possible.

PetrVys commented 1 week ago

I don't think ExifTool is able to get this directly, but extracting the info from this output is simple:

exiftool.exe -X -ee -n -QuickTime:StillImageTime -QuickTime:TrackDuration ##LiveImageName##.MOV

will output something like this:

<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about='IMG_0956_orig.MOV'
  xmlns:et='http://ns.exiftool.org/1.0/' et:toolkit='Image::ExifTool 12.92'
  xmlns:Track5='http://ns.exiftool.org/QuickTime/Track5/1.0/'
  xmlns:Track1='http://ns.exiftool.org/QuickTime/Track1/1.0/'
  xmlns:Track2='http://ns.exiftool.org/QuickTime/Track2/1.0/'
  xmlns:Track3='http://ns.exiftool.org/QuickTime/Track3/1.0/'
  xmlns:Track4='http://ns.exiftool.org/QuickTime/Track4/1.0/'>
 <Track5:StillImageTime>-1</Track5:StillImageTime>
 <Track1:TrackDuration>2.84333333333333</Track1:TrackDuration>
 <Track2:TrackDuration>2.84333333333333</Track2:TrackDuration>
 <Track3:TrackDuration>2.84333333333333</Track3:TrackDuration>
 <Track4:TrackDuration>2.84333333333333</Track4:TrackDuration>
 <Track5:TrackDuration>1.335</Track5:TrackDuration>
</rdf:Description>
</rdf:RDF>

Locate the line with StillImageTime; and then get the TrackDuration on the same track where StillImageTime was present. That is your keyframe in seconds (1.335 in this case).