UFOID / UFO-Detector

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

Automatically checking video codecs #39

Closed hekkup closed 8 years ago

hekkup commented 8 years ago
UFOID commented 8 years ago

Thanks for this. Unfortunately, there is an issue with the codecs on Windows. I cannot use cv::VideoWriter with FFV1 as the codec in Windows in my two test environments. The recording starts but all I get is

[ffv1 @ 027884a0] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556)

in the output. Because of this I use the raw codec (0) and convert the video to FFV1 with ffmpeg.exe in the current recorder class and then delete the temp video. I think this logic has to stay like this. I found the support for lossless codecs in cv::VideoWriter to be quite poor on Windows so I make use of the ffmpeg binary

hekkup commented 8 years ago

Ok, I fixed this in the commit 3253ecb.

Actually, the raw codec is now IYUV, not 0. If you check the video files written with codec 0 with cv::VideoCapture and get the codec property, you will get codec I420 which belongs to IYUV family. That's the case at least in Linux. You can verify it's really a raw codec by checking the result video with avprobe/ffprobe.

UFOID commented 8 years ago

Yes I can confirm that IYUV works fine as the raw codec. However I still have two issues on Windows: Everytime I exit the application I get

[ffv1 @ 02658900] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556)

Doesn't matter which codec is selected. I thought it is because m_videoCodecSupportInfo->init() is called before m_videoCodecSupportInfo->removeSupport(CV_FOURCC('F', 'F', 'V', '1'), VideoCodecSupportInfo::OpenCv) so I changed that but the problem still persists. It happens only if init() is called.

Second problem is that FFV1 doesn't show up as an option in the settings even though ffmpeg.exe is in QCoreApplication::applicationDirPath()

hekkup commented 8 years ago

The error message you get when starting the program (I guess you meant starting, not exiting?) is because VideoCodecSupportInfo::init() tries out every codec with OpenCV and ffmpeg/avconv to get the support status. The check is done by actually writing a video file, then checking the codec in it. It is a known bug that using FFV1 with OpenCV causes error messages. So the error message is a "feature", not a bug. :) I thought it is possible to suppress the error message but it's not critical. VideoCodecSupportInfo::removeSupport() must be called only after init().

The missing FFV1 support doesn't sound good. Here's how to test it with the unit test. 1st, run the unit test in test/testVideoCodecSupportInfo. You shouldn't see any problems. 2nd, see testVideoCodecSupportInfo.cpp lines 169-171 and 236-238 (commit 3253ecb1). You see commented out checks for codec support. Fix the bug in 236 (should be rawSupported) and uncomment all the lines. You should change the lines so that they are correct for your system, meaning if e.g. the raw codec is supported then QVERIFY(rawSupported) should pass. Then run the test again, and again there shouldn't be any problem.

UFOID commented 8 years ago

I accidentally merged it when testing:/

Anyway, the FFV1 error message does only show up after exiting but I know it happens before that. It just gets written to the console at the end. All tests pass in testVideoCodecSupportInfo but I think the wrong file is in master right now. Sorry for the mess. Need to do some reverts later

UFOID commented 8 years ago

Please create the pull request again