UFOID / UFO-Detector

UFO Detector
http://ufoid.net/
GNU General Public License v3.0
54 stars 8 forks source link

Video content is not saved, just the header (Linux) #10

Closed hekkup closed 8 years ago

hekkup commented 8 years ago

Video is saved but it is empty. I guess this only happens in Linux. Probably it has to do with the fact that Linux uses avconv for video encoding.

UFOID commented 8 years ago

What codec setting is selected?

There are three options working on Windows:

This process is not implemented to work with linux yet as you can tell. Only Raw video should work on linux.

hekkup commented 8 years ago

Ok, found the reason. The webcam resolution must be accurately given in the settings. Even if the webcam aspect ratio passes, there will be problems if the resolution is not what's in settings. cv::VideoWriter won't write anything if the desired resolution doesn't match the actual frame size. Besides, the desired resolution changes in the middle of recording (-> another bug). Well, that's now more ok after changing the settings but now there's a problem with finishing video recording:

00:06 OpenCV Error: Assertion failed (dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0)) in resize, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/imgwarp.cpp, line 1825 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/imgwarp.cpp:1825: error: (-215) dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0) in function resize The program has unexpectedly finished.

UFOID commented 8 years ago

cv::VideoWriter won't write anything if the desired resolution doesn't match the actual frame size

I am not sure I understand what you mean by desired resolution and actual frame size

hekkup commented 8 years ago

Desired resolution is what the user sets in the settings. Actual frame size is what the camera actually gives. They can differ even if aspect ratio check passes. That's more reason to some day try to make the list of actually available resolutions.

It seems the saving of videos is unstable. Now I got two videos saved okay, but on the third video there was this error message: * Error in `.../Detector': free(): invalid pointer: 0x00007f8358000078 * This happened before the recorder and frame updater thread were being joined in ActualDetector::stopRecording() -- I know that because I added some debug messages into it.

I'll be digging more. Unit tests would be cool in this kind of situations, and in general.

UFOID commented 8 years ago

That's interesting. I haven't seen this problem before. If you look at the Camera class you can see that the camera cv::VideoCapture is created with the width and hight properties of the resolution specified in the settings. That's the resolution that works in the GUI and the detection algorithm. I don't understand why it wouldn't work in the Recorder class.

I have had some strange behaviour with cv::VideoCapture and cv::VideoWriter. Sometimes I think I should use something different than OpenCV for the reading / writing of video

hekkup commented 8 years ago

Ha, the reason was thumbnail size for video was not set for aspect ratio 1.2222 which caused cv::resize() to crash the app.

The null pointer bug may return to haunt at some point though.