UFOID / UFO-Detector

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

Automatically checking video codecs (2) #40

Closed hekkup closed 7 years ago

hekkup commented 8 years ago

This pull request is a duplicate of UFOID/UFO-Detector#39. It was merged accidentally so needed to create a new one.

Changes

Issues

UFOID commented 8 years ago

So again, all test in testVideoCodecSupportInfo pass (With ffv1 error packet too small error). The issue is that FFV1 doesn't show up as an option in the Settings. The logic should be (for Windows): If raw codec is supported and ffmpeg.exe is found allow for FFV1 option in the settings. I don't see the check for the ffmpeg.exe in the VideoCodecSupportInfo.

Another issue is that the dummy file is created at start up but not removed.

hekkup commented 8 years ago

If you run ffmpeg -codecs in Windows, what's the line which has ffv1 codec? Encoding support is decided from that line with a regular expression (videocodecsupportinfo.cpp:184) so let's verify it.

For avconv -codecs in Linux the line is: DEV..S ffv1 FFmpeg video codec #1

Also important is the legend which is printed first. In Linux it is:

Codecs:
 D..... = Decoding supported
 .E.... = Encoding supported
 ..V... = Video codec
 ..A... = Audio codec
 ..S... = Subtitle codec
 ...I.. = Intra frame-only codec
 ....L. = Lossy compression
 .....S = Lossless compression
UFOID commented 8 years ago

Same for me: DEV..S ffv1 FFmpeg video codec #1

Test output seems ok:

***** Start testing of TestVideoCodecSupportInfo ***** Config: Using QtTest library 5.6.0, Qt 5.6.0 (i386-little_endian-ilp32 shared (dynamic) release build; by GCC 4.9.2) PASS : TestVideoCodecSupportInfo::initTestCase() PASS : TestVideoCodecSupportInfo::constructor() PASS : TestVideoCodecSupportInfo::testOpencvSupport() QDEBUG : TestVideoCodecSupportInfo::testEncoderSupport() Checking encoder support status inside test took 88 ms QDEBUG : TestVideoCodecSupportInfo::testEncoderSupport() Checking encoder support status by VideoCodecSupportInfo took 89 ms PASS : TestVideoCodecSupportInfo::testEncoderSupport() PASS : TestVideoCodecSupportInfo::initialize() PASS : TestVideoCodecSupportInfo::isSupportedMethods() PASS : TestVideoCodecSupportInfo::codecName() PASS : TestVideoCodecSupportInfo::toFromFourcc() PASS : TestVideoCodecSupportInfo::rawVideoCodecStr() PASS : TestVideoCodecSupportInfo::removeSupport() PASS : TestVideoCodecSupportInfo::fillExpectedCodecs() PASS : TestVideoCodecSupportInfo::cleanupTestCase() Totals: 12 passed, 0 failed, 0 skipped, 0 blacklisted ***** Finished testing of TestVideoCodecSupportInfo ***** [ffv1 @ 0051bda0] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 03248420] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 03248420] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 03248420] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 03248420] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556)

hekkup commented 8 years ago

In the latest commit (e3c7cbb) I see this in Linux in testVideoCodecSupportInfo:

QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() Codec support
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "rawvideo" in OpenCV: yes
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "rawvideo" in ffmpeg/avconv: yes
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "ffv1" in OpenCV: no
[ffv1 @ 0x1519160] Error getting output packet.
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "ffv1" in ffmpeg/avconv: yes
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "lagarith" in OpenCV: no
QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "lagarith" in ffmpeg/avconv: no
PASS   : TestVideoCodecSupportInfo::fillExpectedCodecs()

Could you please check it in Windows?

I would really like to get the automatic codec detection to work. It means more flexibility, and it takes into account different setups people have. There are different builds of ffmpeg/avconv so it's not 100% guaranteed hard-coded codec stuff will work.

Edit: the point with the modified unit test is to try to find out whether the bug is in the VideoCodecSupportInfo or elsewhere.

UFOID commented 8 years ago

I think we can spot the source of the problem in the first two lines. Doesn't find ffv1 in ffmpeg. Strange as I can definitely use ffv1 in my ffmpeg.exe

Codec support "ffv1" in OpenCV: no "ffv1" in ffmpeg/avconv: no "lagarith" in OpenCV: yes "lagarith" in ffmpeg/avconv: no "rawvideo" in OpenCV: yes "rawvideo" in ffmpeg/avconv: no ***** Start testing of TestVideoCodecSupportInfo ***** Config: Using QtTest library 5.6.0, Qt 5.6.0 (i386-little_endian-ilp32 shared (dynamic) release build; by GCC 4.9.2) PASS : TestVideoCodecSupportInfo::initTestCase() PASS : TestVideoCodecSupportInfo::constructor() PASS : TestVideoCodecSupportInfo::testOpencvSupport() QDEBUG : TestVideoCodecSupportInfo::testEncoderSupport() Checking encoder support status inside test took 87 ms QDEBUG : TestVideoCodecSupportInfo::testEncoderSupport() Checking encoder support status by VideoCodecSupportInfo took 85 ms PASS : TestVideoCodecSupportInfo::testEncoderSupport() PASS : TestVideoCodecSupportInfo::initialize() PASS : TestVideoCodecSupportInfo::isSupportedMethods() PASS : TestVideoCodecSupportInfo::codecName() PASS : TestVideoCodecSupportInfo::toFromFourcc() PASS : TestVideoCodecSupportInfo::rawVideoCodecStr() PASS : TestVideoCodecSupportInfo::removeSupport() QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() Codec support QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "ffv1" in OpenCV: no QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "ffv1" in ffmpeg/avconv: no QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "lagarith" in OpenCV: yes [ffv1 @ 004a8540] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 004a8e00] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 004a8e00] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 004a8e00] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) [ffv1 @ 004a8e00] Provided packet is too small, needs to be 2781184 warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:556) QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "lagarith" in ffmpeg/avconv: no QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "rawvideo" in OpenCV: yes QDEBUG : TestVideoCodecSupportInfo::fillExpectedCodecs() "rawvideo" in ffmpeg/avconv: no PASS : TestVideoCodecSupportInfo::fillExpectedCodecs() PASS : TestVideoCodecSupportInfo::cleanupTestCase() Totals: 12 passed, 0 failed, 0 skipped, 0 blacklisted ***** Finished testing of TestVideoCodecSupportInfo *****

hekkup commented 8 years ago

Seems there are no codecs at all for ffmpeg. So something goes wrong with that. I noticed QVERIFY() stuff didn't work in the unit test constructor so I changed it to the init method. If you can figure out the problem directly, then all the better. I think it's the unit test which should catch the possible bugs. On the other hand, the problem might be on MainWindow or settings dialog side which don't have proper unit tests.

hekkup commented 8 years ago

One problem I spotted is the encoder location for Windows. It's QCoreApplication::applicationDirPath()+"/ffmpeg.exe" which means ffmpeg.exe should be copied into the unit test build/run folder. If it's not there the unit test gives wrong results so the possible other bugs are not caught.

UFOID commented 8 years ago

I haven't been able to spot the problem... I copied ffmpeg to the correct dir (The tests won't run without it)

hekkup commented 8 years ago

Is the codec support list the same as before with no support for any codecs in ffmpeg/avconv?

hekkup commented 8 years ago

If you want to help me out with this problem, you could tinker with TestVideoCodecSupportInfo::localTestEncoderSupport(). That's the method which should find out the codecs in ffmpeg/avconv for the test. The lines 198-202 are the most important. You can remove the comment from qDebug() line 200 to check that the method really finds the codec line from ffmpeg output. If there's no output nor codecs found, then this method is wrong, and the rest of the stuff with it.

hekkup commented 7 years ago

At least one problem was that newer versions of ffmpeg/avconv add one space before encoding status chars but older versions don't, and that confused the support detection.

UFOID commented 7 years ago

(Sorry for the delay. I was away from my PC). I can confirm that it seems to work correctly now. FFV1 shows up as an option if ffmpeg.exe is found. Videos are recorded correctly. Thanks for this