mdyusuf000 / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

FrameGrabber.getFrameRate() does not do anything useful #292

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
- Calling getFrameRate() on a FFmpegFrameGrabber object, returns just the 
number that was previously set sith setFrameRate(), so, the requested 
framerate. If the video input does not support that framerate, getFrameRate() 
still returns the default value.
- Calling getFrameRate() on an OpenCVFrameGrabber object returns -1.

For example, we request 30 fps with setFrameRate, but a given webcam only 
supports 15 fps. getFrameRate returns 30 with FFmpegFG, and -1 with OpenCVFG.

What is the expected output? What do you see instead?
I would expect this method to return the actual framerate set in the source (15 
in the example).

What version of the product are you using? On what operating system?
JavaCV 0.4, Ffmpeg 1.1.3

Please provide any additional information below.
SO: Ubuntu 64

Original issue reported on code.google.com by adle...@gmail.com on 9 Mar 2013 at 8:05

GoogleCodeExporter commented 9 years ago
This should actually not be marked as a defect (as it just follow the get/set 
pattern), but as an enhancement (I don't know how to reclassify the bug once 
created).

Original comment by adle...@gmail.com on 9 Mar 2013 at 11:29

GoogleCodeExporter commented 9 years ago
Let's look at FFmpegFrameGrabber.getFrameRate():
    @Override public double getFrameRate() {
        if (video_st == null) {
            return super.getFrameRate();
        } else {
            AVRational r = video_st.r_frame_rate();
            return (double)r.num() / r.den();
        }
    }

and OpenCVFrameGrabber.getFrameRate():
    @Override public double getFrameRate() {
        return capture == null ? super.getFrameRate() : (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
    }

Should they be doing anything differently?

Original comment by samuel.a...@gmail.com on 10 Mar 2013 at 1:23

GoogleCodeExporter commented 9 years ago
There is something strange somewhere. If I specify some huge number for the 
framerate, like 1250, I get the message:

    The driver changed the time per frame from 1/1250 to 1/226

And getFrameRate() returns 226. However, this webcam in this mode only supports 
125 fps (which are the ones I actually am getting).

If I specify a lower value, like 200, getFrameRate() just returns 200.

May there be a different way to retrieve that framerate?

For example (I don't know if it really applies): 
http://libav-users.943685.n4.nabble.com/Retrieving-Frames-Per-Second-FPS-td94653
3.html

Original comment by adle...@gmail.com on 10 Mar 2013 at 1:55

GoogleCodeExporter commented 9 years ago
Well the best would be to check what the ffmpeg program does, and if that does 
what you need, then to implement something similar in 
FFmpegFrameGrabber.getFrameRate()...

Original comment by samuel.a...@gmail.com on 10 Mar 2013 at 11:22

GoogleCodeExporter commented 9 years ago
Issue 391 has been merged into this issue.

Original comment by samuel.a...@gmail.com on 4 Jan 2014 at 2:15

GoogleCodeExporter commented 9 years ago
JavaCV 0.10 now returns the value of  `AVStream.avg_frame_rate` instead of 
`r_frame_rate`:
https://github.com/bytedeco/javacv/issues/63
I hope this fixes this issue as well. Let me know if you still have problems, 
and thanks for reporting!

Original comment by samuel.a...@gmail.com on 27 Dec 2014 at 3:19