Skip to content

Commit f71bf21

Browse files
committed
Unhandled Objective-C exception when playing video
1 parent cc09f5a commit f71bf21

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/highgui/src/cap_avfoundation_mac.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,15 @@ -(int) updateImage {
697697
return;
698698
}
699699

700-
mAssetTrack = [[mAsset tracksWithMediaType: AVMediaTypeVideo][0] retain];
700+
NSArray *tracks = [mAsset tracksWithMediaType:AVMediaTypeAudio];
701+
if ([tracks count] == 0) {
702+
fprintf(stderr, "OpenCV: Couldn't read movie file \"%s\"\n", filename);
703+
[localpool drain];
704+
started = 0;
705+
return;
706+
}
707+
708+
mAssetTrack = [tracks[0] retain];
701709

702710
if ( ! setupReadingAt(kCMTimeZero) ) {
703711
fprintf(stderr, "OpenCV: Couldn't read movie file \"%s\"\n", filename);

0 commit comments

Comments
 (0)