[mythtv-users] replacement for mythtranscode --mpeg2 -l using ProjectX

Tino Keitel tino.keitel at gmx.de
Tue Jul 18 15:15:24 UTC 2006


Hi,

since mythtranscode is quite unusable for my DVB recordings [1], I have
to use ProjectX to edit my recordings to prepare it for DVDs. As
editing in ProjectX is a pain for me, I wrote a little shell script
that takes the MythTV cutlist and uses the ProjectX command line. The
result is an edited MPEG2 file that can be burned to DVD.

The script takes the mpg filename as the only argument and requires
ProjectX (and therefore, a Java runtime environment), mplex and
mencoder. It replaces the original file at the end. In my case, MythTV
can use the new file to watch the recording.

To get expressive filenames for your recordings, so you know what file
to use, you might use mythrename.pl from the contrib directory of the
MythTV distribiution.

It was tested with some recent SVN versions.

Regards,
Tino

[1] http://svn.mythtv.org/trac/ticket/1948
-------------- next part --------------
#!/bin/sh -e

# Copyright (C) 2006, Tino Keitel <tino.keitel+mythcutprojectx at tikei.de>

# Usage: mythcutprojectx <recording>
# <recording> is a file recorded by MythTV with a valid DB entry.

# This script will pass the MythTV cutlist to ProjectX.
# The file will be re-multiplexed to be usable as a dvdauthor input file,
# so you can burn it on a DVD.
# If not cutlist is present, the file will just be converted to DVD format.

# Limitations:
# - all audio tracks except the first will be lost
#   (as long as I can't figure out how to replace the mencoder run by something
#   that preserves all audio tracks)

# You might want to customize these two variables
TEMP=please_fill_in_your_the_path_for_the_temporary_files_here
PROJECTX=/path/to/ProjectX.jar

PASSWD=`grep "^DBPassword" /etc/mythtv/mysql.txt | cut -d '=' -f 2-`

if test "$1" 	echo "Usage: mythcutprojectx <recording>"
	echo "<recording> is a file recorded by MythTV with a valid DB entry."
	echo "This file will be replaced with the edited file."
	exit 0
fi

# database schema >53 saves keyframe markers in a separate table
dbver=`echo "select data from settings where value='DBSchemaVer'" |
	mysql -N -u mythtv -p$PASSWD mythconverg`
if test $dbver !	keyframetable="recordedseek"
else
	keyframetable="recordedmarkup"
fi

# chanid and starttime identify the recording in the DB
chanid=`echo "select chanid from recorded where basename=\"$1\";" |
	mysql -N -u mythtv -p$PASSWD mythconverg`

starttime=`echo "select starttime from recorded where basename=\"$1\";" |
	mysql -N -u mythtv -p$PASSWD mythconverg`

# get cutlist (mark type 0 and 1)
list=`echo "select mark from recordedmarkup
	where chanid=$chanid and starttime='$starttime' and type in (0,1) order by mark;" |
	mysql -N -u mythtv -p$PASSWD mythconverg |
	tail -n +2 |
	head -n -1`

echo "CollectionPanel.CutMode=0" > cutlist$$

# find the key frame (mark type 9) right before each cut mark,
# extract the byte offset, write it into the ProjectX cutlist
for i in $list ;
	do echo "select offset from $keyframetable
	where chanid=$chanid and starttime='$starttime' and type=9 and mark >	order by offset;" |
	mysql -N -u mythtv -pPASSWD mythconverg |
	head -1
done >> cutlist$$

# de-multiplex with the created cutlist
java -jar "$PROJECTX" -name tempcut$$ -out $TEMP -cut cutlisti$$ "$1" || :

# re-multiplex, pipe it through mencoder so that we get a file that
# can be processed by dvdauthor
mplex -o /dev/stdout -V -f 8 $TEMP/tempcut${$}.m2v $TEMP/tempcut${$}*.mp2 |
mencoder -oac copy -ovc copy -of mpeg -mpegopts format=dvd:vbitrate00 -o "$1.cut" /dev/stdin

rm -f "$1"
mv "$1.cut" "$1"

mythcommflag --rebuild -f "$1"
rm -f $TEMP/tempcut${$}*
rm -f cutlist$$



More information about the mythtv-users mailing list