rs / SDAVAssetExportSession

AVAssetExportSession drop-in replacement with customizable audio&video settings
MIT License
805 stars 212 forks source link

iOS 9.3.1 iPhone 5c - Uncaught exception: NSInvalidArgumentException: -[CADisplayLink integerValue]: unrecognized selector sent to instance 0x1a13ff10 #53

Closed Jabbaquack closed 8 years ago

Jabbaquack commented 8 years ago

Hi, This is really stumping me, so any help would be appreciated !

The code was working well on the iPhone 5c, before the update to iOS 9.3.1 and the currently works with other iOS devices (iPhone 6 running iOS 9.3.1, and iPad Air 2 running iOS 9.2.1).

The video is a recording made earlier on the same device and then export from .mov to .mp4 using the following code:

` SDAVAssetExportSession *encoder = [SDAVAssetExportSession.alloc initWithAsset:avAsset];

encoder.outputFileType = AVFileTypeMPEG4;
encoder.outputURL = [NSURL fileURLWithPath:destPath];
encoder.shouldOptimizeForNetworkUse = YES;
encoder.videoSettings = @{
    AVVideoCodecKey: AVVideoCodecH264,
    AVVideoWidthKey: videoWidthHeightKey,
    AVVideoHeightKey: videoWidthHeightKey,
    AVVideoCompressionPropertiesKey: @
    {
        AVVideoAverageBitRateKey: @3000000,
        AVVideoProfileLevelKey: AVVideoProfileLevelH264BaselineAutoLevel,
    }
};
`

encoder.audioSettings = @{ AVFormatIDKey: @(kAudioFormatMPEG4AAC), AVNumberOfChannelsKey: @2, AVSampleRateKey: @44100, AVEncoderBitRateKey: @128000, };

encoder.videoComposition = videoComposition;

[encoder exportAsynchronouslyWithCompletionHandler:^
{
    switch ([encoder status]) {

        case AVAssetExportSessionStatusFailed:
            [[NSOperationQueue mainQueue] addOperationWithBlock:^ {
                [self ReportError: formatConversionFailed];
            }];
            break;

        case AVAssetExportSessionStatusCancelled:
            break;

        default:

....`

The exception appears to occur in the exportAsynchronouslyWithCompletionHandler:(void (^)())handler on the line (however, I can't see what's wrong with that - and it works fine with other devices):

self.videoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:self.videoSettings];

The Xcode output log is:

-[CADisplayLink integerValue]: unrecognized selector sent to instance 0x1a13ff10 2016-04-23 00:43:10.273 appname[8240:2536741] Uncaught exception: NSInvalidArgumentException: -[CADisplayLink integerValue]: unrecognized selector sent to instance 0x1a13ff10 ( 0 CoreFoundation 0x24289ba3 <redacted> + 150 1 libobjc.A.dylib 0x23a46dff objc_exception_throw + 38 2 CoreFoundation 0x2428f4d5 <redacted> + 0 3 CoreFoundation 0x2428d12b <redacted> + 702 4 CoreFoundation 0x241b7358 _CF_forwarding_prep_0 + 24 5 AVFoundation 0x29cdfae9 <redacted> + 1620 6 AVFoundation 0x29cdf075 <redacted> + 60 7 AVFoundation 0x29cd9663 <redacted> + 334 8 AVFoundation 0x29cdde77 <redacted> + 42 9 AVFoundation 0x29cd9663 <redacted> + 334 10 AVFoundation 0x29c4f3bd <redacted> + 340 11 AVFoundation 0x29c4f263 <redacted> + 30 12 AVFoundation 0x29c4f1d5 <redacted> + 44 13 testappplayscotland01 0x010992dd -[SDAVAssetExportSession exportAsynchronouslyWithCompletionHandler:] + 3590

Jabbaquack commented 8 years ago

Resolved.

I had some old code using manual memory allocations with -fno-objc-arc flag set, which has worked fine until now. So converted the older code to use ARC and it is now working again on the iPhone 5c running iOS 9.3.1.