[mythtv-users] Cleaning up DVB-T recordings

Martin Bene Martin.Bene at icomedias.com
Tue Feb 2 12:28:47 UTC 2010


Hi Nick,

> Extra for experts: extract the cutlist from myth's database and
> convert it to the format projectx uses, then use it with the -cut
> option to projectx. I haven't tried that. I have used the projectx gui
> to create a cutlist and saved it. I cannot remember offhand how the
> projectx cutlist format compares to what appears in the myth database
> after a commflag or manual edit.

You could check out the old mythburn project on sourceforge (precursor to mytharchive). Mythburn could optionally use projectx for commercial cutting. Here's the code from that old project:

echo "cutlist found, applying and remultiplexing for DVD format"
${scripts}/mpeg2cut-px.sh ${myfolder} $videoformat $recode_ntsc ${mythtvlocation}/${file} ${tempdir}/${file}


#! /bin/sh
# mpeg2cut-px.sh
#
# vim:ts=4:sw=4:ai:et:si:sts=4
#
# Cut MPEG2 files to remove cutlists...
#
# Prerequisites:
#    projectx
#    mplex
#    Xvfb
#
# warning: won't make frame accurate cuts - cutpoints get rounded to the nearest GOP boundry
#
# Usage: mpeg2cut_px basedir inputfile outputfile
#        basedir/temp/cutlist.txt is a cutlist as returned by getmyth.sh

function cutlist_x {
        #generate project x cutlist
        #cutlist is just a sequence of cutpoints
        #first entry is cut-in, i.e start recording
        line=0
        rm ${tempdir}/cutlist_x.txt 2>/dev/null
        cat ${tempdir}/cutlist.txt | while read
        do
                first=$(echo $REPLY|cut -f1 -d-)
                second=$(echo $REPLY|cut -f2 -d-)

                if [ "$line" -eq "0" ]; then
                        echo "(2) use Frame number for cuts" > ${tempdir}/cutlist_x.txt
                        if [ "$first" -ne "0" -a "$first" != "" ]; then
                                echo "0" >> ${tempdir}/cutlist_x.txt
                        fi
                fi
                line=$((line+1))
                if [ "$first" != "" -a "${first}0" -ne "0" ]; then
                        echo $first >> ${tempdir}/cutlist_x.txt
                fi
                if [ "$second" != "" ]; then
                        echo $second >> ${tempdir}/cutlist_x.txt
                fi
        done
}

XVFB=`which Xvfb`
if [ -n "$XVFB" ]; then
        mode=XVFB
        export DISPLAY=:33.0
        ${XVFB} :33 -screen 0 640x480x8 2> /dev/null > /dev/null &
        XVFB_PID=$!
else
        if [ -n "$DISPLAY" ]; then
                mode=X
        else
                echo "Neither Xvfb nor DISPLAY varibale found, can't run projectx"
                exit 1
        fi
fi
pushd . > /dev/null
myfolder=$1
shift
videoformat=$1
shift
recode_ntsc=$1
shift
file=$1
shift
outfile=$1
shift

base=`basename ${file} .nuv`

# read config file
cfg=${myfolder}/mythburn.conf
if ! [ -r "$cfg" ]; then
        echo "Error: can't read config file $cfg; program stopped"
        exit 1
fi
. $cfg


if [ -z "$projectx" ]; then
        echo "projectx not defined, can't cut commercials"
        exit 1
fi

cd ${tempdir}

echo Filename \"${file}\"
echo OutFile \"${outfile}\"

echo Cutting out commercials + demultiplexing with projectx
cutlist_x
nice -n 19 ${projectx} -o . -p cutlist_x.txt $file

if ! [ -f "${base}_X.log" ]; then
        echo "Error running projectx, no log file created. giving up"
        exit 1
fi

# sort audiofiles, optionaly reencode first track to ac3 for NTSC
audio=`${myfolder}/scripts/prepare_audio.sh ${myfolder} ${base}_X.log ${videoformat} ${recode_ntsc}`

echo Remultiplexing video
echo mplex -o ${outfile} -f 8 ${base}.m2v ${audio}
nice -n 19 mplex -o ${outfile} -f 8 ${base}.m2v ${audio} > /dev/null

echo Cleaning up
rm ${base}.m2v ${audio} cutlist_x.txt
if [ "$mode" == "XVFB" ]; then
        # Shut down Xvfb if we used it
        kill ${XVFB_PID} 2>/dev/null
fi
popd > /dev/null
exit 0



More information about the mythtv-users mailing list