[mythtv-users] automating commercial removal

Craig G. craig at goranson.org
Wed Sep 26 04:55:50 UTC 2007


I have been running a script very similar to the one that Chris posted. 
Like others here I have experiences the last "blurp" of the show getting cut 
due to the way that USA and other channels use credits etc at the end of 
their shows.   I like autotranscoding shows, as I tend to record a lot and 
then watch them over mythweb while not at home.  So its nice to have the 
commercials removed for me.   So I have my system setup to automatically cut 
out commercials on select programs.

 I have modified the entry for the commercial flagger job to run a custom 
shell script that handles the normal flagging of the commercials, then 
copies the skiplist to the cutlist.   For "low value" programs that I don't 
care if there is 100% accuracy on the skip list I just schedule the 
autotranscode job to run, and have it honor the skip list.   For programs 
that are high value I don't run the auto transcode, so I can always edit the 
skip list for accuracy later.  Main difference between mine and Chris's 
script is that I have some primitive shell code that strips the last 
commercial break from the skip list prior to copying the skiplist to the 
cutlist.   If there are two or more commercial skips, then I have it ignore 
the last skip.   If there is one skip, I just ignore the one skip. 
Eventually I want to rewrite this in Perl and make it more intelligent and 
have it pull out commercial skips that are very short, as those are likely 
incorrectly flagged  parts in shows.  Also would be cool to put together 
something for mythweb where you could "preview" just the commercial cuts 
(small video clips), then approve the commercial cuts before transcoding. 
But don't have that kind of time on my hands right now to tackle something 
like that.

When scheduling a job I want to automatically remove commercials, I just 
check the "autotranscode" box in the scheduling.   Since the commercial 
flagging job runs when the program starts recording, it will have completed 
prior to the autotranscoding starting, which only starts after the program 
is done recording.  For programs I don't want to automatically remove 
commercials, I just don't check the autotranscode on the schedule.   (if 
there was a program where you absolutely didn't want a cutlist applied, just 
setup a job with "mythcommflag -f -c %CHANID% -s %STARTTIME% --clearcutlist" 
and have that job run on that program)


I configured the commflag command in mythtv to be:
   mythremovecomm.sh -j %JOBID% -V %VERBOSELEVEL%

Then in the mythremovecomm.sh file I have:
----------------------cut---------------------------
  #!/bin/sh
  mythcommflag $1 $2 $3 $4
  EXITCODE=$?

  #####################################################
  #  Gets Skip list,
  ####################################################
  list1=`mythcommflag --getskiplist $1 $2 |sed  -n 's/Commercial Skip List: 
//p'`
  count=`echo $list1 | grep -c ","`

  ############################################################
  #if 1 or more z'comma"  found then there are least two commercials
  #less then one comma means one or zero commercial skip
  ###########################################################
   if [ $count -gt 0 ]; then
     # strip last commercial from list
     list=`echo $list1 | sed -re 's/(.+),.+$/\1/'`
  else
     exit $EXITCODE
  fi
  mythcommflag $1 $2 $3 $4 --setcutlist $list
  exit $EXITCODE
------------------------------------cut---------------------------

Hope that proves useful, it seems to have been working well for me.   But 
haven't done any kind of detailed testing.

Craig

----- Original Message ----- 
From: "Tom Metro" <tmetro+mythtv-users at gmail.com>
To: "Discussion about mythtv" <mythtv-users at mythtv.org>
Sent: Tuesday, September 25, 2007 6:24 PM
Subject: Re: [mythtv-users] automating commercial removal


Chris Pinkham wrote:
> If you are confident enough in the commercial flagger to always copy
> the commercial skip list to the cut list automatically before
> transcoding...

I'm not. As I mentioned in another thread, the flagger routinely messes
up on the last commercial break and includes the last segment of the
show as part of the break. (I understand why this happens. The last
segment is brief, and probably has scene changes of a frequency similar
to commercials.)

But I'm also not transcoding universally. I was planning to only
transcode certain "low value" shows. And shows in which the last segment
only contains credits. (Although I'm considering a hack of having a user
job that deleted the last cut from the cut list.)

Assuming most people don't universally transcode shows, I'd think
copying the flag list to the cut list by default would be fairly
harmless. If nothing else, it saves a keystroke when you go to manually
tweak the cut list before running a manual transcode.


>     #!/bin/sh
>     mythcommflag --chanid $1 --starttime $2 -V $3
>     RESULT=$?
>
>     mythcommflag --chanid $1 --starttime $2 -V $3 --gencutlist
>     exit $?

What's the purpose of "RESULT=$?" if RESULT is never used?


> I think you can even put multiple commands in the "Commercial Flagger
> command" setting as long as they are separated by a semi-colon.  So you
> might want to try the following instead of making a wrapper shell script:
>
> mythcommflag -c %CHANID% -s %STARTTIME% -V %VERBOSELEVEL% ; 
> mythcommflag -c %CHANID% -s %STARTTIME% -V %VERBOSELEVEL% --gencutlist

I'd substitute && for ;, but otherwise this is the approach I'd try first.

Running mythcommflag --gencutlist ... as a user job seemed to work fine,
but this is something I'd like to apply universally.


>> Feels like there should be an --alsocopycutlist option, or something
>> like that.
>
> Since you'd have to modify the "Commercial Flagger command" anyway to add
> this command line option and it's so easy to do this anyway by calling
> mythcommflag twice, I don't see a big need to add another option.

True. I guess my ideal would be flipping the behavior and adding a
switch to *not* copy the cut list. Copying then becomes the default, and
for those users that universally transcode, they can add the option to
disable it.

  -Tom

_______________________________________________
mythtv-users mailing list
mythtv-users at mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users 



More information about the mythtv-users mailing list