Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9316533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:38:40+00:00 2026-06-19T02:38:40+00:00

I build opencv with ffmpeg support and this is a snippet of my code

  • 0

I build opencv with ffmpeg support and this is a snippet of my code to read a video and iterate through the frames.

if (argc != 3) {
    std::cout<<"Usage: exe input_video_filename skip_frames \n"<<std::endl;
    return 0;
}
char* video_fn = argv[1];
int skip_frames = atoi(argv[2]);
VideoCapture cap;
if(!cap.open(video_fn))
{
    std::cout<<"error reading video"<<video_fn<<std::endl;
    return -1;
}
Mat frame,gray;
int i = 0;
double score = 0;
vector<double> scores;
while(true)
{
    if(!**cap.retrieve(frame)**)
    {
        std::cout<<"error retrieve frame"<<std::endl;
        break;
    }
    if(i%skip_frames)
    {
        cvtColor(frame,gray,CV_BGR2GRAY);
        double sc = compute_cpbdm(gray);
        std::cout<<sc<<std::endl;
        scores.push_back(sc);
    }

}

The program succeed to read the video at line cap.open(video_fn) but fail to retrieve frame from VideoCapture at the line if(!cap.retrieve(frame)). I tried with mp4 and avi but it always fails.Does anyone encountered similar problem? How to solve it? Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:38:41+00:00Added an answer on June 19, 2026 at 2:38 am

    you’re using capture.retrieve(frame), then there should be a capture.grab() before that.

    alternatively, you can do: capture.read(frame) , which does both at the same time,

    or just capture >> frame; (same thing as read)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a C++ application that uses OpenCV/ffmpeg to capture video frames from
I am trying to build OpenCV 2.4.1 with OpenGL support, and it keeps faling.
I've followed the directions here to build html documentation https://code.ros.org/trac/opencv/browser/trunk/opencv/doc/README.txt (actually my local copy
This is an odd little thing. I'm using OpenCV 2.4.2 (brew build on OSX
I have a webcam video recorder program built with python, opencv and ffmpeg It
i've implemented this OpenCV build into my iphone project: http://aptogo.co.uk/2011/09/opencv-framework-for-ios/ It builds successfully and
This OpenCV build was working for me a few nights ago. I am trying
I am using cmake-gui trying to build opencv but get this error: CMake Error
I've used this tutorial to build OpenCV on ubuntu. Everything goes well until I
I am trying to build OpenCV 2.3.0 with FFMPEG enabled. Since Ubuntu 11.10 only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.