[mythtv-users] Commercial Detection

Lawrence Rust lvr at softsystem.co.uk
Sun Mar 11 10:36:37 UTC 2012


On Sun, 2012-03-11 at 09:08 +1000, Anthony Giggins wrote:
> 
> 
> On 9 March 2012 19:30, Lawrence Rust <lvr at softsystem.co.uk> wrote:
>         On Fri, 2012-03-09 at 13:44 +1000, Anthony Giggins wrote:
>         >
>         >
>         > On 8 March 2012 20:47, Lawrence Rust <lvr at softsystem.co.uk>
>         wrote:
>         >         On Wed, 2012-03-07 at 23:13 +0000, Thomas Boehm
>         wrote:
>         >         > Martin Moores wrote:
>         >         > > On 7 March 2012 21:58, Doug Lytle
>         <support at drdos.info
>         >         > > <mailto:support at drdos.info>> wrote:
>         >         > >
>         >         > >
>         >         > >     And I believe there was an external script
>         based on
>         >         volume changes on a
>         >         > >     channel that people have reported good
>         results with.
>         >         > >
>         >         > >
>         >         > > Indeed, I never got around to trying that, but
>         many said
>         >         they had a lot
>         >         > > of success with it:
>         >         >
>         >         > It works very well for me. I changed the script so
>         that it
>         >         runs on all
>         >         > channels, not only the white listed ones. If there
>         is really
>         >         a show
>         >         > which doesn't get marked properly, I still press
>         the forward
>         >         button a
>         >         > few times as I did before, but most of the times
>         it works.
>         >         >
>         >         > The mythcommflag which comes with MythTV takes
>         much longer
>         >         and basically
>         >         > doesn't work at all in the UK.
>         >
>         >
>         >         I use a script based on the wiki article
>         >         www.mythtv.org/wiki/Mythcommflag-wrapper with good
>         success on
>         >         most UK
>         >         Freesat channels.
>         >
>         >         I found that changing the silence threshold to -76
>         dB from -70
>         >         significantly improved accuracy.  Also, decreasing
>         the
>         >         coalescence time
>         >         from 400 to 360 seconds reduced the prevalence of
>         false
>         >         positives.  The
>         >         last useful tweak is to the awk program to add 'cut
>         to
>         >         beginning' or
>         >         'cut to end' without leaving 'dangling' frames.
>         >
>         >         This generally leaves a few frames of ads/titles
>         before and
>         >         after each
>         >         cut.  The only annoyance is that the post ad cut
>         doesn't
>         >         position to a
>         >         keyframe so the cut isn't entirely invisible.  I'm
>         working on
>         >         that and
>         >         back tracking from the start of cut to detect a
>         scene change.
>         >
>         >         The script can be found here:
>         >
>         http://www.softsystem.co.uk/download/mythtv/mythcommflag-silence.sh
>         >
>         >         To run it as a user job, start mythtv-setup and find
>         >         General/JobQueue
>         >         (Global) and set the Ad-detection command:
>         >         mythcommflag-silence.sh -j %JOBID% -C
>         >
>         >         The -C option copies the list to the cutlist.
>         >
>         >         --
>         >
>         > I get an error in this script when running from a command
>         prompt
>         >
>         > ./mythcommflag-silence.sh -c 4010 -s "2011-09-29 21:10:00"
>         > -i /storage3/recordings/4010_20110929211000.mpg
>         > mythcommflag-silence.sh: line 11: syntax error near
>         unexpected token
>         > `cat'
>         
>         
>         This looks like a difference in sh implementations.  From the
>         sh man
>         page 'man sh|grep -A 3 Function':
>         
>           Functions
>             The syntax of a function definition is
>         
>                   name () command
>         
>         See also the POSIX doc on shell functions:
>         http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05
>         
>         As I understand it, a valid function can be:
>         
>         f1() echo "f1"
>         
>         Note the absence of { } around the command - these are for
>         grouping and
>         are theoretically optional although I am aware that bash
>         requires them.
>         The Help() function in mythcommflag-silence.sh doesn't include
>         the
>         braces and so is tickling this particular bug.  For reference
>         I'm
>         running Ubuntu and sh is provided by dash, what distribution
>         and sh are
>         you running?
>         
>         Pragmatically I updated the script to include the braces which
>         should
>         fix this problem.  Would you confirm that this change fixes
>         the problem
>         for you?  Thanks for your feedback.
>         
>         --
>         Lawrence
>         
>         
> I'm running mythdora 12.23 aka fedora 12
> 
> Was this right ?
> 
> Help() { cat >&2 <<END
> Detect commercial breaks in a TV recording using silence detection.
> Usage: ${myname##*/} [options]
> Options:
>   -b <n>    Coalesce ad breaks upto [$MAXCOMMBREAKSECS] Seconds
>   -c <n>    Channel ID
>   -d <f>    Min silence duration [$SILENCE_DURATION] Seconds
>   -i <path> Recording filename
>   -j <n>    Job ID
>   -s <s>    Start-time
>   -t <n>    Silence threshold [$SILENCE_THRESHOLD] dB (-96..0)
>   -C        Copy to cutlist [$COPYTOCUTLIST]
>   -M <path> MythTV settings folder [$MYTHCONFDIR]
>   -h        Display this help and exit
>   -V        Display version and exit
> 
> A job ID, channel ID and start-time or a recording filename must be
> specified.
> END
> }

Yes that's one change.

> I tried running with with dash but it doesn't seem to do anything
> 
> $ dash ./mythcommflag-silence.sh
> -i /storage3/recordings/4010_20110929211000.mpg
> $

The script is probably exiting with a syntax error.  I suspect that
Fedora 12 dash requires braces around functions and there are 2 other
functions (Version & Log) that omitted them.  The easiest way is to
download the revised script from here:
http://www.softsystem.co.uk/download/mythtv/mythcommflag-silence.sh

-- 
Lawrence


More information about the mythtv-users mailing list