iOS 13/iOS 13.1 has a bug with AVAssetWriter/AVCaptureMovieFileOutput metadataItems. I am trying to set creation date in quicktime file that is set as metadata item.
var metadata:[AVMetadataItem] = []
let date = Date()
let calendar = Calendar.current
let year = calendar.component(.year, from: date)
let month = calendar.component(.month, from: date)
let day = calendar.component(.day, from: date)
let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
let timezone = TimeZone.current
let timezoneStr = timezone.abbreviation()
let creationDateMetaData = AVMutableMetadataItem()
creationDateMetaData.keySpace = AVMetadataKeySpace.common
creationDateMetaData.key = AVMetadataKey.commonKeyCreationDate as NSCopying & NSObjectProtocol
creationDateMetaData.locale = locale
creationDateMetaData.value = String(format:"%04ld-%02ld-%02ld %02ld:%02ld:%02ld %@",year, month, day, hou
r, minute, second, timezoneStr!) as NSCopying & NSObjectProtocol
metadata.append(creationDateMetaData)
And I use PHPhotoLibrary to save video to Photo Library. The Photo library shows all sought of weird dates such as 1 Jan 1970 or sometimes 2 Sept 469231. Is this a bug with Photos framework or AVFoundation or I am doing something wronf, and is there a known workaround? Currently, I have to forcefully update the creation date via PHAssetCreationRequest when saving it using PHPhotoLibrary.