Ask Your Question

dub_dub's profile - activity

2018-11-14 10:06:30 -0600 received badge  Notable Question (source)
2017-04-03 19:11:43 -0600 received badge  Popular Question (source)
2015-10-19 05:59:39 -0600 received badge  Student (source)
2015-04-08 14:44:35 -0600 asked a question OpenCV + FFmpeg: Error when recording lossless video

I'm trying to record a lossless video from a webcam using opencv. I would like to use the FFV1 codec for this.

I open my video writter like this:

theVideoWriter.open(filename,CV_FOURCC('F','F','V','1'), 30, cv::Size(1280,720), true);

I can successfully open the video writter but while recording I get following error message:

[ffv1 @ 26d78020] Provided packet is too small, needs to be 8310784

The resulting video is not playable. Other FFmpeg codecs like FMP4 work fine.

What does that error mean and how can I fix it?

2014-11-16 05:53:31 -0600 received badge  Editor (source)
2014-11-16 05:49:47 -0600 commented answer VideoCapture: access the same webcam from two threads

Thanks for the answer. I'm still relatively new to multithreading. Could you post a example on how to achieve that? I tried putting the VideoCapture in its own class Camera that has a thread safe getWebcamFrame() function and then pass the pointer to my Camera object to both my threads but my program crashes as soon as the second threads starts grabbing its frames from the object. Please see the updated question for the code for my Camera class.

2014-11-15 19:35:27 -0600 commented question VideoCapture: access the same webcam from two threads

It says "1 Answer" but I can't see anything?:(

2014-11-15 10:46:50 -0600 asked a question VideoCapture: access the same webcam from two threads

Simple question but I have been struggling a lot trying to implement a solution: I have a c++ program with two threads. One is a motion detection algorithm and the other one records a video. The Detector tells the Recorder when to start and stop the video recording. They both need to read video frames from the same webcam. How can I achieve this?

If I create two VideoCapture objects in each class the program crashes on start when it tries to open the second VideoCapture with the same index. There must be a way around that.

//edit: Code for my Camera where I tried to implement a thread safe get function. I think something is wrong with my attempt

Camera::Camera(){

    myWebcam.open(INDEX);
    myWebcam.set(CV_CAP_PROP_FRAME_WIDTH, WIDTH);
    myWebcam.set(CV_CAP_PROP_FRAME_HEIGHT, HEIGHT);

}

cv::Mat Camera::getWebcamFrame(){

    myMutex.lock();
    myWebcam.read(videoFrame);
    myMutex.unlock();
    return videoFrame;
}