econsysqtcam / qtcam

QtCAM is a free, Open Source Linux Webcamera Software with more than 10 image control settings, extension settings and Color space switching.
http://www.e-consystems.com/opensource-linux-webcam-software-application.asp
GNU General Public License v3.0
183 stars 94 forks source link

Incorrect frame rate for video recording #13

Open Setig opened 7 years ago

Setig commented 7 years ago

I want to draw your attention to the part of file "videostreaming.cpp", function "Videostreaming::recordBegin(int, QString, QString)":

    v4l2_frmivalenum frmival;
    enum_frameintervals(frmival, m_pixelformat, m_width, m_height);
#if LIBAVCODEC_VER_AT_LEAST(54,25)
    bool tempRet = videoEncoder->createFile(fileName,(AVCodecID)videoEncoderType, m_capDestFormat.fmt.pix.width,m_capDestFormat.fmt.pix.height,frmival.discrete.denominator,frmival.discrete.numerator,10000000);
#else
    bool tempRet = videoEncoder->createFile(fileName,(CodecID)videoEncoderType, m_capDestFormat.fmt.pix.width,m_capDestFormat.fmt.pix.height,frmival.discrete.denominator,frmival.discrete.numerator,10000000);
#endif

Video recording is independent of the FPS, which we choose in the ComboBox "frame rate", in the section "Video Capture Settings".

You can see an example: If you run Qtcam, and then select the minimum value of "frame rate" (5-10 FPS), and start to record video, then the video will be recording with the basic (standard) FPS, but the camera itself will work with the FPS which we have pointed out earlier "frame rate". Because of this, the video file with an incorrect value FPS: video recording will be slower, and playing video file will be accelerated. The same problem can be obtained by selecting a different value in comboBox "frame rate", different from the standard...

I think that part of the code, which I quoted above, should be replaced by this:

    v4l2_fract temp_interval;
    if (m_has_interval) {
        temp_interval = m_interval;
    }
    else {
        v4l2_frmivalenum frmival;
        enum_frameintervals(frmival, m_pixelformat, m_width, m_height);
        temp_interval = frmival.discrete;
    }
#if LIBAVCODEC_VER_AT_LEAST(54,25)
    bool tempRet = videoEncoder->createFile(fileName,(AVCodecID)videoEncoderType, m_capDestFormat.fmt.pix.width,m_capDestFormat.fmt.pix.height,temp_interval.denominator,temp_interval.numerator,10000000);
#else
    bool tempRet = videoEncoder->createFile(fileName,(CodecID)videoEncoderType, m_capDestFormat.fmt.pix.width,m_capDestFormat.fmt.pix.height,temp_interval.denominator,temp_interval.numerator,10000000);
#endif
econsysqtcam commented 7 years ago

Thanks for your valuable input. We will have a look and fix in our code as suggested.