Skip to content

videoCapture in iOS returns 1 for all properties #6450

Closed

Description

@benjamincarp
  • OpenCV version: 3.1
  • Host OS: Mac OS X 10.11.4
  • iOS

    In which part of the OpenCV library you got the issue?

    opening a file with videoCapture

Expected behaviour

it would open the video, give me access to the video's properties and frames

Actual behaviour

it claims to open the file but all properties return 1 and trying to get frames fails
I found this stack overflow post from 2 years ago that describes the same problem http://stackoverflow.com/questions/22006052/opencv-on-ios-videocapture-properties-always-return-1

Code example to reproduce the issue / Steps to reproduce the issue

Please try to give a full example which will compile as is.

#import <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int Tracking::processFile(string fileIn)
{  
  VideoCapture cap(fileIn); // open the video file for reading

  if ( !cap.isOpened() )  // if not success, exit program
  {
    cout << "Cannot open the video file: " << fileIn << endl;
    return -1;
  }
  else{
    cout << "File Open " << fileIn << endl;
  }

  double dFps = cap.get(CAP_PROP_FPS); //get the frames per seconds of the video
  cout << "Frames per second = " << dFps << endl;

  double dWidth = cap.get(CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
  double dHeight = cap.get(CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  cout << "Frame Size = " << dWidth << "x" << dHeight << endl;

  Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));

  double dFrameCount = cap.get(CAP_PROP_FRAME_COUNT);
  cout << "Frame count = " << dFrameCount << endl;

  return 0;
}

Activity

  1. logic1988 commented on Sep 23, 2016

    @logic1988
    Contributor

    I got the same problem in iOS, anybody had the easy way to solve it?

  2. yijiasu commented on Jan 18, 2017

    @yijiasu

    This problem is still unfixed

  3. davidfant commented on Jul 20, 2018

    @davidfant

    Has anyone figured this out?

  4. hannesoud commented on Jul 30, 2018

    @hannesoud

    I am getting same issue. Anyone figured this out ?

  5. nastenkomisha commented on Aug 6, 2018

    @nastenkomisha

    The same problem. Any plans to fix it?

  6. maja3d commented on Jan 29, 2019

    @maja3d

    It returns 1 for this property CAP_PROP_FRAME_COUNT
    Please fix

  7. mshabunin commented on Sep 25, 2019

    @mshabunin
    Contributor

    Please check the fix from PR #15464

  8. added a commit that references this issue on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions