[mythtv] New Method for Commercial Detection.

Lucas Meijer lucas at mach8.nl
Wed May 3 08:33:22 UTC 2006


Robert Dunn wrote:
> Now i'm in the process of getting myself a PVR-350 and a linux box to 
> test on. Does anyone who is familiar with the commercial detection in 
> myth feel like giving me a hand by explaining briefly how 
> CommDetectorBase etc all fits in with the operation of MythTV, ill get 
> it eventually but a quick summary just a paragraph just to point me in 
> the right direction would be wonderful.
>   

Commercial detection is done my a program called mythcommflag which 
you'll find in (surprise)
programs/mythcommflag. mythcommflag can be 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 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.
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:

- gotNewCommercialBreakList()

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).

- statusUpdate()

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.

- breathe()

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.


What you need to start with is modify mythcommflag to also provide 
CommDetector implementations with a means
to get at the audio bytes. I remember discussing this with isaac a while 
ago, and he suggested making a class similar
to AudioOutputNULL, that provides its user with a means to access the 
actual sound data. mythcommflag should then
instantiate your new AudioOutput class when it is making the 
NuppelVideoPlayer.   (NuppelVideoPlayer::SetAudioOutput())

A CommDetector implementation can then call GetAudioOutput() on the 
NuppelVideoPlayer it is provided, and get its
hands on the actual audio data...

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.

That should hopefully get you started,  ah well, I might as well add 
this to the wiki..

Bye, Lucas


More information about the mythtv-dev mailing list