Hey there @gchiste, thanks for getting back.
I implemented the proper video settings to tell the asset writer to output an MV-HEVC video, but upon testing this implementation, by passing an MV-HEVC video through my compressVideo function, my app crashes with the below error:
“Thread 3: "*** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] Compression property MVHEVCLeftAndRightViewIDs is not supported for video codec type hvc1"”
Here’s what my compressVideo function looks like when the crashing occurs:
let videoReaderSettings: [String: Any] = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32ARGB]
let multiviewCompressionProperties: [String: Any] = [kVTCompressionPropertyKey_MVHEVCVideoLayerIDs as String: MVHEVCVideoLayerIDs,
kVTCompressionPropertyKey_MVHEVCViewIDs as String: MVHEVCVideoLayerIDs,
kVTCompressionPropertyKey_MVHEVCLeftAndRightViewIDs as String: MVHEVCVideoLayerIDs,
kVTCompressionPropertyKey_HasLeftStereoEyeView as String: true,
kVTCompressionPropertyKey_HasRightStereoEyeView as String: true
]
let videoSettings: [String: Any] = [AVVideoCodecKey: AVVideoCodecType.hevc,
AVVideoHeightKey: videoTrack.naturalSize.height,
AVVideoWidthKey: videoTrack.naturalSize.width,
AVVideoCompressionPropertiesKey: multiviewCompressionProperties
]
let assetReaderVideoOutput = AVAssetReaderTrackOutput(track: videoTrack, outputSettings: videoSettings)
let assetReaderAudioOutput = AVAssetReaderTrackOutput(track: audioTrack, outputSettings: nil)
if assetReader.canAdd(assetReaderVideoOutput) {
assetReader.add(assetReaderVideoOutput)
} else {
completion(.failure(NSError(domain: "VideoUploader", code: -4, userInfo: [NSLocalizedDescriptionKey: "Couldn't add video output reader"])))
return
}
if assetReader.canAdd(assetReaderAudioOutput) {
assetReader.add(assetReaderAudioOutput)
} else {
completion(.failure(NSError(domain: "VideoUploader", code: -5, userInfo: [NSLocalizedDescriptionKey: "Couldn't add audio output reader"])))
return
}
let audioInput = AVAssetWriterInput(mediaType: .audio, outputSettings: nil)
let videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings)
videoInput.transform = videoTrack.preferredTransform
I have also tried multiple different implementations to configure the output settings for MV-HEVC (such as the one below), but I am still thrown the same error and my app still crashes.
let videoSettings: [String: Any] = [
AVVideoCodecKey: AVVideoCodecType.hevc,
AVVideoHeightKey: videoTrack.naturalSize.height,
AVVideoWidthKey: videoTrack.naturalSize.width,
AVVideoCompressionPropertiesKey: [
AVVideoAverageBitRateKey: bitrate,
kVTCompressionPropertyKey_MVHEVCVideoLayerIDs as String: [0, 1],
kVTCompressionPropertyKey_MVHEVCViewIDs as String: [0, 1],
kVTCompressionPropertyKey_MVHEVCLeftAndRightViewIDs as String: [0, 1],
kVTCompressionPropertyKey_HasLeftStereoEyeView as String: true,
kVTCompressionPropertyKey_HasRightStereoEyeView as String: true
]
]
I have also tried simply removing the line of code “kVTCompressionPropertyKey_MVHEVCLeftAndRightViewIDs as String: MVHEVCVideoLayerIDs”, but upon doing so my app continues to crash and I receive a different error relating to the configuration (the one below):
"Thread 7: "*** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] Compression property MVHEVCViewIDs is not supported for video codec type hvc1"”
I should also note that I'm working on an M3 iMac with sonoma 14.3.1 as my OS, so I don’t think hardware should be the issue. I’ve also tested multiple different MV-HEVC video files but they all crash as well.
Sorry for the long response, just figured I’d lay it all out to give out all the context I can. If there’s any changes I can make or anything you know of that will help fix this crashing error and allow me to compress MV-HEVC videos with the output also being MV-HEVC it would be greatly appreciated. Thanks.