Skip to content

Commit fa36e76

Browse files
authored
Merge pull request opencv#8979 from sabzo:issue/8305_unhandled_objective_c_exception_video_avi_playback
Unhandled Objective-C exception when playing video
2 parents e397794 + f71bf21 commit fa36e76

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)