It doesn't look like Live Photo Info value gets added properly. I don't think the datatype is utf-8?That project you linked will not work in iOS17 set as live wallpaper since it includes old pairing of jpg and mov via only identifier, which is not the case now {because other keys added for that motion thing}
Regarding adding hard coded metadata you can do it simple e.g. adding metadata in assetWriter?.metadata =
[addone, addtwo, addthree ... 4 x .. n ]. you just iterate though an array of values [0, 0.02, 0.03 etc] and add whatever values in order to fill all video total duration.
let addone = addSampleTime()
lett addtwo = addSampleTime2()
let addthree = addLiveTime()
let Allmediatimed = "3 0.00823200028389692 16939217 155 5.94521753062658e-15 -6.44374300689783e-15 0.27380958199501 0.575768828392029 1.92900002002716 3.30649042129517 4 0 -1 0 0 0 0 0 0 0 0 0 9.80908925027372e-45 -0.17872442305088 3212927435 33811 49646"
private func addSampleTime()->AVMetadataItem { // here you can add ofc. input as float 0.0 .. 0.99 and format it as String float + " s"
let item = AVMutableMetadataItem()
let keyContentIdentifier = "Sample Time" // metadatakey quickTimeMetadataKeyContentIdentifier
let keySpaceQuickTimeMetadata = "mdta"
item.key = keyContentIdentifier as (NSCopying & NSObjectProtocol)?
item.keySpace = AVMetadataKeySpace(rawValue: keySpaceQuickTimeMetadata)
item.value = "0 s" as (NSCopying & NSObjectProtocol)?
item.dataType = "com.apple.metadata.datatype.UTF-8"
return item
}
private func addSampleTime2()->AVMetadataItem { // here you can add ofc. input as float 0.0 .. 0.99 and format it as String float + " s"
let item = AVMutableMetadataItem()
let keyContentIdentifier = "Sample Duration" // metadatakey quickTimeMetadataKeyContentIdentifier
let keySpaceQuickTimeMetadata = "mdta"
item.key = keyContentIdentifier as (NSCopying & NSObjectProtocol)?
item.keySpace = AVMetadataKeySpace(rawValue: keySpaceQuickTimeMetadata)
item.value = "0.03 s" as (NSCopying & NSObjectProtocol)?
item.dataType = "com.apple.metadata.datatype.UTF-8"
return item
}
private func addLiveTime()->AVMetadataItem { //this is repetitive add it whenever you add the 2 keys above
let item = AVMutableMetadataItem()
let keyContentIdentifier = "Live Photo Info" // metadatakey quickTimeMetadataKeyContentIdentifier
let keySpaceQuickTimeMetadata = "mdta"
item.key = keyContentIdentifier as (NSCopying & NSObjectProtocol)?
item.keySpace = AVMetadataKeySpace(rawValue: keySpaceQuickTimeMetadata)
item.value = self.Allmediatimed as (NSCopying & NSObjectProtocol)?
item.dataType = "com.apple.metadata.datatype.UTF-8"
return item
}
Code can be simplyfied with a single function and enum as input type, have limited time to work on this .
The exiftool will report them exactly how you hard coded so no problem to add into your asset metadata.
I used:
let Allmediatimed = "3 0.0145119996741414 1844164067 128 86.7509384155273 14.2610721588135 0.396545708179474 -0.0815095826983452 1.92900002002716 4 4 0 -1 0 0 0 0 0 0 0 0 0 9.80908925027372e-45 0.264391481876373 3209850598 10779 50282"
exiftool reports:
774905907 6.7126802605344e-07 960049457 876033593 1.6503396693679e-07 1.71542069438146e-07 1.6967970850601e-07 1.55186320745308e-19 1.56020131727458e-19 1.03838319773786e-05 53 48 57 51 892417080 53 50 55 51 775172384 6.44692410567416e-10 6.60107104977214e-07 4.12621545820002e-08 4.00463724681277e-11 892746035 13620 12343