How to write a new method of commercial detection
Commercial detection is done my a program called mythcommflag which you'll find in (surprise) programs/mythcommflag. mythcommflag is usually initiated by a backend. It is expected to return a list of commercial start & end points (often refered to as the breakmap).. This map gets stored in the database. Not only after commflagging has finished, but it gets updated as the commflagger goes along, so we can flag a live recording. It also sends out events to frontends that are currently watching this recording that the breakmap has been updated..
mythcommflag takes care of looking up the file requested, stuffing results into the database & notifying frontends. The actual work is being done by an implementation of the virtual class CommDetectBase. If you want to add a new method of commercial detection, you have to make a new implemenation of this class. There are few restrictions on what the implementation can choose to do or not do. The implementation is provided a NuppelVideoPlayer*, which it can use to seek around in the recording, and analyze the video.
It is expected to pause when instructed to, as well as stop when its instructed to. The base class provides several events that you should signal:
signal this event if your detection code has a new idea on what might or might not be commercial (This doesn't perse mean this is going to be another detected commercial. It could also change its mind on something it has considered commercial a while before).
call this with a string to indicate some sort of progress message. mythcommflag will output this either to the console or to the database depending on how it is run.. the current implementation says things like "looking for logo" "processing video 34%" or stuff like that.
call this from time to time, to give mythcommflag an opportunity to do some maintainence (like checking if we received a command to stop or pause).. I think it is currently called after processing 10 frames or something like that.
You should add your CommDetector class to the commdetector factory, and just assign a number to it. There is a command line option for mythcommflag to specify which commdetector implementation to chose.
Your implementation should be aware that the entire recording might not be finished recording yet, so be careful. Take a look at ClassicCommDetector to see how to properly deal with this situation.