[mythtv-users] Nuvexport, transcode, and commercial cutting

Fedor Pikus fpikus at gmail.com
Fri Jun 17 03:55:56 UTC 2005

On 6/16/05, Dan Christensen <jdc at uwo.ca> wrote:
> Fedor Pikus <fpikus at gmail.com> writes:
> > I'm trying to set up my mythtv box to automatically transcode old
> > recordings and cut commercials while it's there. I have commercial
> > flaggin run automatically after recording, I have a nice script which
> > determines which is the oldest file to transcode, now all I need is to
> > get nuvexport to run.
> I can't help with your question, but I'd like to see the script you
> use for determining which file to transcode.  I'd like to
> automatically transcode shows which are at least a week old and larger
> than a given size, and maybe I could use your script as a base.

Well, this is the script I cobbled together in a few minutes
yesterday. I was going to run it from cron every hour or so (it exits
if another mythtranscode is already running). The only problem is, the
command it's supposed to run does not work, hence the last two lines
echo commands I want instead of running them.

#! /bin/sh
# Run mythtranscode on the oldest non-transcoded recording.

# Directory where MythTV stores recordings

# Minimum age of the file before it is transcoded, in seconds since the epoch.
# There are 86400 seconds in a day, 604800 seconds in a week. 

# Log file for the script

# If mythtranscode is running, exit now.
ps ax | grep -q '[0-9] mythtranscode'
if [ $? -eq 0 ] ; then

# Current time, in seconds since the epoch.
NOW=`date +%s`

# Get the name of the oldest recording which was not transcoded.
for FILE in `ls -tr *.nuv` ; do
  if [ "`file -b $FILE`" == "MPEG sequence, v2, program multiplex" ] ; then
if [ "x$FILE" == "x" ] ; then
  exit 1

# Get the modification time stamp, in seconds since the epoch.
MODTIME=`stat -c%Y "$FILE" 2> /dev/null`
if [ "x$MODTIME" == "x" ] ; then
  exit 1

# Calculate the age of the file, quit if it's too new.
AGE=`expr $NOW - $MODTIME`
if [ $AGE -lt $MIN_AGE ] ; then

# Parse file name and construct parameters for mythtranscode.
# File name is "<channel>_YYMMDDhhmmss_*".
CHANNELID=`expr "$FILE" : '\([0-9]*\)'`;
DATETIME=`expr "${FILE#${CHANNELID}_}" : '\([0-9]*\)'`;
DATETIME=`echo $DATETIME | sed -e

# Transcode the file.
#echo "`date`: Transcoding old recording $FILE" >> $LOG
echo mythcommflag --gencutlist --file "$FILE"
echo mythtranscode -V 3 -c $CHANNELID -s "$DATETIME" -p autodetect -d -l
Fedor G Pikus (fpikus at gmail.com)

More information about the mythtv-users mailing list