我正在生成具有1个视频轨道+ 2个音频轨道的视频文件。
我将自定义元数据直接添加到AVAssetWriter中,并且可以这样做:
static func metadataItem(_ identifier: String, value: String?) -> AVMetadataItem {
let item = AVMutableMetadataItem()
item.keySpace = AVMetadataKeySpace.quickTimeMetadata
item.key = identifier as NSCopying & NSObjectProtocol
if let value = value {
item.value = value as NSCopying & NSObjectProtocol
}
return item.copy() as! AVMetadataItem
}
self._assetWriter?.metadata = [Utils.metadataItem("IRISTrack1", value: "Camera"), Utils.metadataItem("IRISTrack2", value: "External Mic")]
如果我直接在AVAsetwriter中设置此元数据,结果就可以了
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.m4v':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2018-07-03T21:22:19.000000Z
IRISTrack1 : Camera
IRISTrack2 : External Mic
Duration: 00:00:03.98, start: 0.000000, bitrate: 1487 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 1293 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2018-07-03T21:22:20.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2018-07-03T21:22:20.000000Z
handler_name : Core Media Data Handler
Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2018-07-03T21:22:20.000000Z
handler_name : Core Media Data Handler
问题是我想将元数据添加到特定的流/轨道(AVAssetWriterInput)
input = AVAssetWriterInput(mediaType: .audio, outputSettings: audioSettings, sourceFormatHint: outputSettings)
input.expectsMediaDataInRealTime = false
input.metadata = [Utils.metadataItem("IRISTrack", value: name)]
如您所见,记录文件后,它在元数据中不显示任何内容。
有人知道这是怎么回事吗?预先感谢