Mythcommflag-wrapper

name=unnamed
author=Cowbutt
webpage=none
short=Wrapper script for mythcommflag to use silence detection to detect commercials
long=A simple bash script based on Silence-detect.sh that wraps mythcommflag and can be used manually (via 'Begin Advert Detection' menu option in recording browser) to use silence detection for commflagging for certain UK TV channels.
file=none
category=Scripts
supports=S21:unset,S22:unset,S23:unset,S231:unset,S24:yes,S241:unset,S25:unset,S251:unset,S252:unset,S26:yes,S27:unset,S28:unset

Author

Cowbutt

Description

A simple bash script based on Silence-detect.sh that wraps mythcommflag and can be used manually (via 'Begin Advert Detection' menu option in recording browser) to use silence detection for commflagging for certain UK TV channels.

Supports

Contents

Prerequisites

This script needs mytharchivehelper which may be included in the MythArchive package ( No longer needed for 0.26 ).Ensure that it is installed on your machine. It also needs [ffmpeg] and [mp3splt]. It's likely that these are packaged for your distro, either directly, or by a third-party repository (e.g. ATrpms for Fedora).

Install wrapper script in place of mythcommflag

Install this script to somewhere accessible by the backend. In mythtv-setup, the command used to run for commercial detection can be modified. The mythcommflag option is a special phrase, telling the jobqueue to run

${PREFIX}/bin/mythcommflag -j %JOBID% -V %VERBOSELEVEL%

If you define any string other than mythcommflag, the command options must be explicitly defined, such as

Edit script variables

Edit the environment variables in the wrapper script according to your local installation.

Enable commflagging

Check that commflagging is allowed in mythtv-setup (i.e. the JobAllowCommFlag setting should be 1).

Test

In the 'Watch Recordings' browser, select a recording that was from a channel included in the script's whitelist (Film4, Dave, Dave ja vu, ITV1-4, ITV1 +1, ITV2 +1), hit menu, then Jobs, then 'Begin Advert Detection'). Within a few minutes, that recording should be commflagged appropriately.

Future Planned Improvements

Fill in the TODOs. Done, apart from automatic "flag all unflagged recordings" mode. Maybe when it can be trusted to not go haywire...

Expand the channel whitelist ("Five" tested once and failed, others???)

More sanity checks of mysql client exit codes and parsed variables.

Refine $CUTLIST generation so that we print $start instead of ($finish*25-25) if ($finish*25-25) < ($finish*25+1).

Per-channel profiles instead of whitelisting.

Experiment with other mp3splt options for other channels. Contributions here particularly welcome!

Merge this into the real mythcommflag. Will probably need a new column in the channels table to signify which commflagging method should be used, and that in turn will require some work to the channel-editor UI of mythtv-setup.