5

我已经通过手机的摄像头用AVCaptureMovieFileOutputObject 捕捉视频,

我想将新的元数据添加到文件中,

我尝试使用AVAssetExportSession它,它有效

但是我猜它花费了很多时间,这种方法重新编码了文件,

我只想添加新的元(位置),

我尝试使用setMetadata方法AVCaptureMovieFileOutput

但我不知道该怎么做,

我试试

元:

AVMutableMetadataItem *newItem = [AVMutableMetadataItem metadataItem];
newItem.identifier = [AVMutableMetadataItem identifierForKey:AVMetadataQuickTimeMetadataKeyLocationISO6709 keySpace:AVMetadataKeySpaceCommon];
newItem.key = AVMetadataQuickTimeMetadataKeyLocationISO6709;
newItem.value = [self gpsStringForVideo:gps];

第一的:

[_movieFileOutput setMetadata:@[meta]];
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];

但我无法得到代表的回应。

然后:

[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
[_movieFileOutput setMetadata:@[meta]];

我可以正常开始记录,但输出文件不包含任何信息!

有人有什么建议吗?谢谢!

4

1 回答 1

3

这对我有用:

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)

对于 Objective-C,你不需要强制转换NSString

于 2016-10-03T05:19:16.933 回答