[mythtv-users] A clustered PVR just rocks...
belcampo
belcampo at zonnet.nl
Fri Jan 18 09:25:15 UTC 2008
> > Between my desktop, my frontend, and my backend I've got 5
> > cpus distributed over the home network catching up on the backlog.
> >
> > That's just too cool...
>Ummm, how?
>I had to transcode two HD shows last night and it took *forever*. I
>sat there working on my laptop that was doing nothing at all and
>wondered whether I could use it for any good?
It is stolen from everywhere, it's rough but I do it this way:
#!/bin/sh -e
# Copyright (C) 2006,2007, 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
# AppleTV options
bitrate=2500:bframes=3:ref=1:me=umh:subme=5:no-fast-pskip=1:cabac=0:trellis=1
# iPod options
bitrate=1500:bframes=0:ref=1:me=umh:subme=6:no-fast-pskip=1:cabac=0:level_idc=30:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all
TEMP=/raid/tv/scratch
PROJECTX=/usr/share/java/ProjectX.jar
#. ~/.mythcutprojectxrc
test -f /etc/mythtv/mysql.txt && . /etc/mythtv/mysql.txt
test -f ~/.mythtv/mysql.txt && . ~/.mythtv/mysql.txt
case $1 in
-h|--help)
echo "Usage: mythcutprojectx <recording> | -V | -h"
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
;;
-V|--version)
echo "mythcutprojectx v0.2"
exit 0
;;
esac
if ! test -d "$TEMP" ; then
echo "Please set \$TEMP to an existing directory,"
echo "or configure it in ~/.mythcutprojectxrc"
exit 1
fi
if ! test -f "$PROJECTX" ; then
echo "Please point \$PROJECTX to the ProjectX.jar file,"
echo "or configure it in ~/.mythcutprojectxrc"
exit 1
fi
if ! which mplex >/dev/null ; then
echo "mplex not found in \$PATH."
exit 1
fi
if ! which mencoder >/dev/null ; then
echo "mencoder not found in \$PATH."
exit 1
fi
if ! which java >/dev/null ; then
echo "java not found in \$PATH."
exit 1
fi
echo "CollectionPanel.CutMode=2" > cutlist$$
#add test for only 1 cutpoint, not necessary, it produces 5 identical
cutpoints and projectx discards the doublures
mythcommflag --getcutlist -f "$1" | grep Cutlist | cut -d ":" -f 2 | cut
-d " " -f 2 | cut -d "-" -f 2 | cut -d "," -f 1 >> cutlist$$
mythcommflag --getcutlist -f "$1" | grep Cutlist | cut -d ":" -f 2 | cut
-d " " -f 2 | cut -d "-" -f 2 | cut -d "," -f 2 >> cutlist$$
mythcommflag --getcutlist -f "$1" | grep Cutlist | cut -d ":" -f 2 | cut
-d " " -f 2 | cut -d "-" -f 2 | cut -d "," -f 3 >> cutlist$$
mythcommflag --getcutlist -f "$1" | grep Cutlist | cut -d ":" -f 2 | cut
-d " " -f 2 | cut -d "-" -f 2 | cut -d "," -f 4 >> cutlist$$
mythcommflag --getcutlist -f "$1" | grep Cutlist | cut -d ":" -f 2 | cut
-d " " -f 2 | cut -d "-" -f 2 | cut -d "," -f 5 >> cutlist$$
# de-multiplex with the created cutlist
java -jar "$PROJECTX" -name tempcut$$ -out $TEMP -cut cutlist$$ -demux
"$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:tsaf -vf
harddup -noskip -o "$1.cut" /dev/stdin
mv "$1" "${1}.old"
mv "$1.cut" "$1"
mythcommflag --clearcutlist -f "$1"
mythcommflag --rebuild -f "$1"
rm -f $TEMP/tempcut${$}*
rm -f cutlist$$
rm -f "${1}.old"
rm -f /raid/tv/scratch/par* /raid/tv/scratch/tmp/*
cd /raid/tv
c () { echo "scale=2;$*" | bc -l; }
rm -f $1.idx
frames=$(avidemux2_cli $1 --info | grep "Number of frames" | cut -d " "
-f 7)
tm=$(c $frames/25)
p1=$(c $tm/5)
# I want 5 pieces, which is the amount of cpu-cores I have
p2=$(c $p1/.48)
p3=$(c $p2+1)
# Add one because first frame is frame 0
p4=$(c $p3*.48)
# PAL DVB-S has a keyframe every .48 second
p5=$(c $p4*25)
# The cutpoint I want, which is a i-frame
lastframe=$(c $frames-1)
A1=0
B1=$(echo $p5 | cut -d "." -f 1)
A2=$(echo $p5 | cut -d "." -f 1)
B2=$(c $A2+$B1)
A3=$B2
B3=$(c $A3+$B1)
A4=$B3
B4=$(c $A4+$B1)
A5=$B4
B5=$(echo $lastframe | cut -d "." -f 1)
echo block1 $A1-$B1 block2 $A2-$B4 block3 $A5-$B5
echo "block2 is triplesized for it's for a faster and dual-core machine"
mencoder $1 -oac lavc -ovc lavc -vf cropdetect -o /dev/null >
/tmp/cropdetect & PID=$!; sleep 50; kill "$PID"
CROP="$( awk '/-vf/{moo=$19} END{sub(").","", moo); print moo}'
/tmp/cropdetect )"
if [ "$CROP" = "" ]
then
export CROP="crop=720:576:0:0"
else
echo "The expected cropvalues are" $CROP
fi
# /usr/bin/avidemux2_cli $1 --rebuild-index
sed -i -e "s/app.load.*\;/app.load\(\"\/raid\/tv\/$1.idx\"\)\;/g" -e
"s/app.addSegment.*/app.addSegment(0,0,$frames\)\;/g" -e
"s/app.markerA=.*\;/app.markerA=$A1\;/g" -e
"s/app.markerB=.*\;/app.markerB=$B1\;/g" -e
"s/app.save.*\;/app.save\(\"\/raid\/tv\/$1.1.mp4\"\)\;/g" /raid/tv/1-5.js
sed -i -e "s/app.load.*\;/app.load\(\"\/raid\/tv\/$1.idx\"\)\;/g" -e
"s/app.addSegment.*/app.addSegment(0,0,$frames\)\;/g" -e
"s/app.markerA=.*\;/app.markerA=$A2\;/g" -e
"s/app.markerB=.*\;/app.markerB=$B4\;/g" -e
"s/app.save.*\;/app.save\(\"\/raid\/tv\/$1.2.mp4\"\)\;/g" /raid/tv/2-5.js
sed -i -e "s/app.load.*\;/app.load\(\"\/raid\/tv\/$1.idx\"\)\;/g" -e
"s/app.addSegment.*/app.addSegment(0,0,$frames\)\;/g" -e
"s/app.markerA=.*\;/app.markerA=$A5\;/g" -e
"s/app.markerB=.*\;/app.markerB=$B5\;/g" -e
"s/app.save.*\;/app.save\(\"\/raid\/tv\/$1.3.mp4\"\)\;/g" /raid/tv/3-5.js
sed -i -e "s/app.load.*\;/app.load\(\"\/raid\/tv\/$1.idx\"\)\;/g" -e
"s/app.addSegment.*/app.addSegment(0,0,$frames\)\;/g" -e
"s/app.markerA=.*\;/app.markerA=$A1\;/g" -e
"s/app.markerB=.*\;/app.markerB=$B5\;/g" -e
"s/app.save.*\;/app.save\(\"\/raid\/tv\/audio.mp4\"\)\;/g" /raid/tv/audio.js
/usr/bin/avidemux2_cli $1 --rebuild-index
avidemux2_cli --run /raid/tv/1-5.js &
ad3 avidemux2_cli --run /raid/tv/2-5.js &
server avidemux2_cli --run /raid/tv/3-5.js
avidemux2_cli --run /raid/tv/au$1.1.audio.js
MP4Box -add $1.1.mp4#video -cat $1.1.mp4#video -cat $1.2.mp4#video -cat
$1.3.mp4#video -add audio.mp4#audio $1.mp4
More information about the mythtv-users
mailing list