I already capture video via phone's camera with AVCaptureMovieFileOutput
Object,
I want to add new meta data into file,
I try to use AVAssetExportSession
to do it, it works !
BUT it cost a lot of time, I guess, this method has re-encode the file,
I just want to add new meta(Location),
I try to use setMetadata
method in AVCaptureMovieFileOutput
But I have no idea about how to do so,
I try
meta :
AVMutableMetadataItem *newItem = [AVMutableMetadataItem metadataItem];
newItem.identifier = [AVMutableMetadataItem identifierForKey:AVMetadataQuickTimeMetadataKeyLocationISO6709 keySpace:AVMetadataKeySpaceCommon];
newItem.key = AVMetadataQuickTimeMetadataKeyLocationISO6709;
newItem.value = [self gpsStringForVideo:gps];
first:
[_movieFileOutput setMetadata:@[meta]];
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
But I can't get delegate's response.
then:
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
[_movieFileOutput setMetadata:@[meta]];
I can start record normally, but output file does not contain any information!
Anyone have any suggestion? Thanks!
This works for me:
let metadata = AVMutableMetadataItem()
metadata.keySpace = AVMetadataKeySpaceQuickTimeMetadata
metadata.key = AVMetadataQuickTimeMetadataKeyLocationISO6709 as NSString
metadata.identifier = AVMetadataIdentifierQuickTimeMetadataLocationISO6709
metadata.value = String(format: "%+09.5f%+010.5f%+.0fCRSWGS_84", location.coordinate.latitude, location.coordinate.longitude, location.altitude) as NSString
movieFileOutput.metadata = [metadata]
movieFileOutput.startRecording(toOutputFileURL: temporaryFileUrl(), recordingDelegate: self)
for Objective-C you don't need casts to NSString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With