简体   繁体   中英

How to get more info from AVFoundationError

I am trying to debug my "videoGenerator" class; which is a class that takes video URLs and audio URLs and merges them together with AVFoundation. When trying to combine some videos with music I get the following error from my exportSession:

Error Domain=AVFoundationErrorDomain Code=-11838 "Operation Stopped" UserInfo={NSLocalizedFailureReason=The operation is not supported for this media., NSLocalizedDescription=Operation Stopped, NSUnderlyingError=0x600003f089f0 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}}

I need to know more than this, and I see that within the error there is a memory address:

NSUnderlyingError=0x600003f089f0

I am wondering if this might hold more info about what exactly is wrong with the media types.

My question is, how can I get something human readable from this memory address within Xcode console other than using $arg1 or is that my only option?

This question is was really more for me about how to debug this, not so much about what the actually issue was that prevented export. Was able to find the method determineCompatibleFileTypes on AVAssetExportSession . This method reports the formats that the input files can be exported to. Turns out an export session cannot export .mp3 files into .mp4 or .m4v formats, a simple check prior to export fixes this issue:

           exportSession.determineCompatibleFileTypes { (fileTypes) in
                if fileTypes.contains(.m4v) {
                    exportSession.outputFileType = .m4v
                } else {
                    exportSession.outputFileType = .mov
                }
            }

We have sort of tight control on what our incoming media types are so this level of simplicity works for us, however, this could easily be expanded to suit a more complex variety.

Rob Napier's comment was really pretty spot on, in that the answer ultimately doesn't lie in the NSUnderlyingError=0x600003f089f0 portion of this error, but instead in the description. My issue was more that I did not read the error and understand initially that it was pointing to the fact that the media I was giving the session was not supported for the media I was asking for from the session.

Hopefully this will help someone else who is new to the AV apis in swift like I am, this took me days to track down :)

Thanks to anyone who took a look, or left a comment!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM