Pursuant to the last post’s naming contest, SvdB had a novel entry of “FFmpeg Make ‘n’ Break”. However, Kostya’s entry of FATE was destined for victory due to its sheer simplicity. And so it comes to pass:
FATE – FFmpeg Automated Testing Environment
Some may have observed that there still are not very many tests yet. I’m being slow and deliberate with these, at least at the outset. My first impulse was to start manually adding tests to validate a bunch of the fringe formats that I’m most familiar with (since I implemented them), as I have done with this test for the FILM system. However, the guru recommended that I put the H.264 conformance suite to the test.
The base directory has 136 samples. Yeah, I’m leaning towards automated tool on this one.
This FATE project is prompting me to craft a variety of special tools to both make my life easier and ensure fewer errors.I could just make a tool to dump all the samples into the database, pass or fail, and let the test failure count tell the story. However, that might not be useful in the same way that it’s not useful to have hundreds of warnings in a compilation — it distracts from real problems (i.e., we know that 100 or so tests are supposed to fail and we don’t notice when a formerly working test just broke).
I also figured out that it’s not so straightforward to dump all the tests in at once, at least not with correct results. Each archive has, at a minimum, a raw H.264-encoded file and the raw YUV file. A decode of the H.264 file is supposed to be bit exact when compared to the raw file. You can feed the raw YUV image into FFmpeg (and encode to the framecrc target for concise stdout text), but only if you know the file’s resolution. The samples usually have readme files included, and they usually mention the resolution, but I’m not going through that much trouble to pick it out. I’ve already worked out the regexps to figure out what the encoded, raw, and readme files can possibly be named.
So my current plotted strategy works like this; for each .zip file in the conformance suite:
- create a short name for the database in the form of, e.g., “h264-conformance-aud_mw_e” for the file AUD_MW_E.zip
- query the FATE database to see if a test spec already has that name
- if the name is taken, the test is already known to have been working in FFmpeg, skip to next file
- unzip the archive
- find the encoded, raw, and readme files
- using the latest build of ‘ffmpeg’, decode the encoded file: ‘ffmpeg -i -f h264 encoded_file decoded.yuv’
- run ‘diff –brief’ against decoded.yuv and the expected output
- if the files are identical, craft a new test spec using the readme file for much of the description, and set the expected stdout text to the output of ‘ffmpeg -i -f h264 encoded_file -f framecrc -‘
- delete files and move on to next archive
That’s the basic idea. Oh yeah, and general sanity considerations, like testing this on a throwaway table first. The point of building the script this way is to make it easy to re-run it again as H.264 fixes are introduced, and add the newly working tests to the test suite that will be run on each build. Currently, 51/136 of the conformance vectors decode in a bit exact manner.
This will be good practice for when it’s time to add conformance suites such as AAC where there is an added challenge that the output will not necessarily be bit exact.
Is there a reason for using diff -brief rather than cmp?
An excellent reason, in fact: I don’t know about the latter. :-) I just looked it up and it appears to function about the same, but without the inconvenience of specifying a command line option.