Skip to content

Commit 8c27ceb

Browse files
committed
Merge pull request opencv#8981 from alalek:port_8979
2 parents b3cd244 + 35a2f2f commit 8c27ceb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/videoio/src/cap_avfoundation_mac.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,15 @@ -(int) updateImage {
694694
return;
695695
}
696696

697-
mAssetTrack = [[mAsset tracksWithMediaType: AVMediaTypeVideo][0] retain];
697+
NSArray *tracks = [mAsset tracksWithMediaType:AVMediaTypeVideo];
698+
if ([tracks count] == 0) {
699+
fprintf(stderr, "OpenCV: Couldn't read video stream from file \"%s\"\n", filename);
700+
[localpool drain];
701+
started = 0;
702+
return;
703+
}
704+
705+
mAssetTrack = [tracks[0] retain];
698706

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

0 commit comments

Comments
 (0)