Difference between revisions of "User:Steveadeff"

From MythTV Official Wiki
Jump to: navigation, search
(Current Dedicated Back End)
m (Current Bedroom Frontend)
Line 150: Line 150:
 
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16813188021 EVGA 112-CK-NF77-A1 ] - LGA 775 NVIDIA nForce e-7150/630i HDMI Micro ATX Intel Motherboard
 
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16813188021 EVGA 112-CK-NF77-A1 ] - LGA 775 NVIDIA nForce e-7150/630i HDMI Micro ATX Intel Motherboard
 
http://www.jobs-khakis-chicks.com/images/mythbedroom/motherboard.jpg
 
http://www.jobs-khakis-chicks.com/images/mythbedroom/motherboard.jpg
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16819116036 Intel Pentium E2160 Allendale 1.8GHz] -  LGA 775 65W Dual-Core Processor Model BX80557E2160 (with aspirations of hitting 3.0GHz or more, currently at 2.8GHz)
+
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16819116036 Intel Pentium E2160 Allendale 1.8GHz] -  LGA 775 65W Dual-Core Processor Model BX80557E2160 (overclocked to 3.0GHz and counting!)
 
http://www.jobs-khakis-chicks.com/images/mythbedroom/cpu.jpg
 
http://www.jobs-khakis-chicks.com/images/mythbedroom/cpu.jpg
 
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16820145034 CORSAIR XMS2 2GB ] - DDR2 SDRAM DDR2 800 (PC2 6400) Dual Channel Kit Desktop Memory Model TWIN2X2048-6400C4
 
* [http://www.newegg.com/Product/Product.aspx?Item=N82E16820145034 CORSAIR XMS2 2GB ] - DDR2 SDRAM DDR2 800 (PC2 6400) Dual Channel Kit Desktop Memory Model TWIN2X2048-6400C4

Revision as of 14:30, 27 June 2008

Me

My Life

I am as of March 2006 an electrical engineer for Parsons in Boston, MA. I help design manufacturing and lab facilities for pharmaceuticals.

I can be reached for mythtv purposes at adeffs_dot_mythtv_at_gmail_dot_com.

My Myth Contributions

I don't really code, but I try to be active in bug and feature testing.

TVRage.com

I developed a TV.com import perl script for adding archived shows to the Watch Recordings DB. I've received help from folks on the myth mailing lists in this project (see source for a roll call).

  • I recently updated it for TVRage.com importing. The new version can be found here (tvragegrab).
    • I've recently been informed of a bug in which the same file can be added twice due to the random chanid generation. I'll be looking into this shortly, but if anyone knows of a quick fix drop me an email =)

6200changer.sh

I wrote a script for handling my DCT-6200 cable boxes connected via firewire that changes the channel and uses firewire_tester to stabilize the connection before Myth tries to record. This has, in the first 7 days of operation (at the time of writing this, the period I've used it) allowed me to not fail in recording a single show.

To use, set it up in mythtv-setup as the channel change script. Give it the GUID of the box as shown in mythtv-setup. The script takes two variables, the first being the GUID (which is why you have to specify it) and the second is the channel number (which mythtv automatically feeds it at the end of the command you give it). The script then changes the channel on that GUID and runs firewire_tester. In running firewire_tester it requires that it show the connection is stable twice. If it iterates 10 times it will automatically re-tune the channel, and after 50 attempts total it will send Myth the "failed" result, otherwise it will send Myth the "success" result.

You can change the script to use another channel changer if you require.

#!/bin/bash
#

GUID=`echo "$1"|sed -r "s/[A-Z]+/\L&/g"`
CHANNEL=$2

NODE=`plugreport | grep $GUID | awk '{if (($1 == "Node")  && ($4 == "'"0x$GUID"'
")) print $2}'`
echo "Node: '$NODE'"
echo "Changing to channel $CHANNEL"
6200ch -v -s -g $GUID $CHANNEL
#maybe a pause is needed?
sleep 4

STABILIZE="1"
COUNT=0
TOTALCOUNT=0
STABLECOUNT=0
echo "Stabilizing Firewire Connection!..."
#maybe an initial run followed by a verification run?

#initial run
firewire_tester -B -r2 -n$NODE

#while [ "$STABILIZE" != "Broadcast Fix: Success (already stable)" ]
while [ $STABLECOUNT -lt 2 ]
do
       STABILIZE=`firewire_tester -B -n$NODE|grep "already stable"`
       if [[ "$STABILIZE" != "Broadcast Fix: Success (already stable)" ]]
       then
               echo "Not Stable! Attempt $COUNT"
               ((COUNT+=1))
               ((TOTALCOUNT+=1))
               if [ $TOTALCOUNT -gt 50 ]
               then
                       echo "FAILED to Stabilize!!"
                       exit 1
               fi
               if [ $COUNT -gt 10 ]
               then
                       6200ch -v -s -g $GUID $CHANNEL
                       COUNT=0
                       firewire_tester -B -r2 -n$NODE
               fi
       else
               echo $STABILIZE
               ((STABLECOUNT+=1))
       fi
done
echo "Stable!"
exit 0

My Systems

I have Comcast cable here in Boston. I use QAM for my HD, and have two DCT-6200 digital cable boxen. The QAM tuners tune the open channels on the Comcast cable line and the DCT-6200 are connected via firewire to the backend.

Current Dedicated Back End

Running SVN trunk 14542 as of 10-October-2007

http://www.jobs-khakis-chicks.com/images/mythbackend/norcocase.jpg

http://www.jobs-khakis-chicks.com/images/mythbackend/msik8nneopt.jpg

http://www.jobs-khakis-chicks.com/images/mythbackend/cpu.jpg

http://www.jobs-khakis-chicks.com/images/mythbackend/powersupply.jpg

Current Dedicated Front End

Running SVN trunk 14542 as of 10-October-2007

http://www.jobs-khakis-chicks.com/images/mythcenter/LC16S.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/ecs%20kn1%20extreme.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/cpu.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/cpucooler.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/powersupply.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/memory.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/videocard.jpg

http://www.jobs-khakis-chicks.com/images/mythcenter/harddrive.jpg

  • 6x500GB SATA RAID5 TV Rips, HDTV conversions, music, etc (2.3TB total)

Frontend Theater/Stereo Equipment

http://www.jobs-khakis-chicks.com/images/hometheater/panasonic_th50pz700u.jpg

http://www.jobs-khakis-chicks.com/images/hometheater/AVR3806.jpg

http://www.jobs-khakis-chicks.com/images/hometheater/HCA-1205A.jpg

  • Paradigm Reference Studio(v.2) 40's, CC and Titan's for surround (which really need to be replaced with a set of 20's or 40's...)
  • Oppo 981HD

http://www.jobs-khakis-chicks.com/images/hometheater/dv981hd.jpg

http://www.jobs-khakis-chicks.com/images/hometheater/PF60.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/MX_500.jpg

Current Bedroom Frontend

http://www.jobs-khakis-chicks.com/images/mythbedroom/MX_500.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/monitor.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/SharpSD-PX2.jpg

  • Antec Silver on Black Veris Fusion - 430 Micro ATX Media Center / HTPC Case with IR receiver (doesn't come with remote, but I have one from my main frontend, and its compat with the MCE-USB remote, you just need to create your own lirc definition file)

http://www.jobs-khakis-chicks.com/images/mythbedroom/case.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/motherboard.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/cpu.jpg

  • CORSAIR XMS2 2GB - DDR2 SDRAM DDR2 800 (PC2 6400) Dual Channel Kit Desktop Memory Model TWIN2X2048-6400C4

http://www.jobs-khakis-chicks.com/images/mythbedroom/memory.jpg

  • COOLER MASTER RR-LIE-L9E1-GP - 95mm Rifle CPU Cooler (not as quiet as I had hoped, will probably replace with a quiter equally or more efficient CPU cooler)

http://www.jobs-khakis-chicks.com/images/mythbedroom/cpucooler.jpg

http://www.jobs-khakis-chicks.com/images/mythbedroom/harddrive.jpg

  • Plextor PX-716A SATA DVD/RW (had it laying around, don't think it works for DVD's anymore, just buy a cheap liteon/etc from Newegg...)

http://www.jobs-khakis-chicks.com/images/mythbedroom/PX716Adrive.jpg

Encoding

I've become somewhat of a mencoder/BASH scripting guru through my many adventures using it and writing scripts. Hopefully, one day, MythArchive will allow for custom profiles with some of the better options/features of mencoder so that such scripts are no longer needed. But for now here are some of the scripts I've written for encoding...

So here are some of my encoding scripts. If you like them feel free to drop me an email (adeffs_dot_mythtv_at_gmail_com) and let me know. If you have some improvements drop me an email as well and I'll update the script here and give you a little shout-out!

HR.HDTV script

I wrote this script to create my own versions of what "the scene" calls HR.HDTV encodes. These look decent on HDTV's up to about 50". Beyond that I highly recommend using x264 at 720p encodes. It may take a lot more processing to get done, but if your TV is that big you'll thank me for recommending it.

So what this script does is convert any 1080i or 720p recording to "HR.HDTV" which is basically a 960x544 resolution file with the original AC3 soundtrack. It will encode to the CD size standard of putting one hour of tv on a CD (ie 44minutes into 700MB, 22minutes into 350MB). It's also a good start to doing other conversions as the options can easily be changes to do things like encode to x264 at 1280x720(hint hint)...

You will need PerlCalc for some math in the script...

#!/bin/bash
#
# My script to create hr.hdtv encodes.
#
# This script will perform the following tasks:
# 1. Analyze the original mpeg for
#       a. play length
#       b. audio size
#       c. frame speed (60fps/30fps)
# 2. Calculate final file size (350MB or 700MB)
# 3. Calculate final video size based on final file
#    size and audio size.
# 4. Encode.
#

#variables
overheadbytes=16
server_default=POT

#Functions
#Video Length Calculation
function VideoSizeCalc() {
        audiosize=`pc $audiobitrate/1000*$totalseconds*0.1220703125/1024`
        echo "Audio Size in MB = $audiosize"
#       audiooverhead=`pc $totalseconds*1000/64`
#       videooverhead=`pc 23.976*$totalseconds`
#       totaloverhead=`pc $audiooverhead+$videooverhead`
#       overheadsize=`pc $totaloverhead*$overheadbytes/1024**2`
#       overheadsize=`echo `${overheadsize:0:4}``
#       echo "(DD) Overhead = $overheadsize MB"
        totalseconds=`echo $totalseconds|sed -e 's/\.[0-9]*//'`
#       echo "(DD) Total Seconds = $totalseconds"
        if [ $totalseconds -lt 1800 ]; then
                totalsize=350
        elif [ $totalseconds -lt 3600 ]; then
                totalsize=700
        else
                echo "I don't know how to handle this length!"
                exit 1
        fi
        echo "Total Size = $totalsize"
#       videosize=`pc $totalsize-$overheadsize-$audiosize` #original formula
        videosize=`pc $totalsize-$audiosize`    # new one since overhead doesn't

                                                #really matter its so small
        videosize=`echo `${videosize:0:3}``
        echo "Videosize = $videosize MB"
}


function FolderNameClean() {
        input=$1
        input=`echo "$input" | sed -e 's/.[Aa][Vv][Ii]//'`
        input=`echo "$input".XviD-MythTV`
        folder_name=$input
}

#test for arguements
if [[ -z "@ARGV" ]]; then
        echo "first arguement is the original mpg"
        echo "second arguement is the new folder name, will be used for filename"
        exit
else
        #Reassign variables
        if [[ ! -e $1 ]]; then
                echo "no such input mpg!"
                exit
        else
                original_name=$1
        fi
        folder_name=$2
        FolderNameClean $2
        file_name=`echo "$folder_name" | tr A-Z a-z`
        # display arguments
        echo "Original mpeg is: $original_name"
        echo "Folder name will be: $folder_name"
        echo "File name will be: $file_name"
fi

#Grab input file information
echo "Determining total file length..."
totalseconds=`mencoder $original_name -ovc copy -nosound -o /dev/null -quiet 2>&1 | awk '/^Video stream:/{print $10+$10/$12}'`
echo "total seconds = $totalseconds"
audiobitrate=`mplayer -vo null -ao null -frames 0 -identify "$original_name" 2>/dev/null | grep "ID_AUDIO_BITRATE" | sed -e 's/ID_AUDIO_BITRATE=0//' | grep "ID_AUDIO_BITRATE" | sed -e 's/ID_AUDIO_BITRATE=//'`
echo "audio bitrate = $audiobitrate"
videowidth=`mplayer -vo null -ao null -frames 0 -identify "$original_name" 2>/dev/null | grep "ID_VIDEO_WIDTH" | sed -e 's/ID_VIDEO_WIDTH=//'`
videoheight=`mplayer -vo null -ao null -frames 0 -identify "$original_name" 2>/dev/null | grep "ID_VIDEO_HEIGHT" | sed -e 's/ID_VIDEO_HEIGHT=//'`
videofps=`mplayer -vo null -ao null -frames 0 -identify "$original_name" 2>/dev/null | grep "ID_VIDEO_FPS" | sed -e 's/ID_VIDEO_FPS=//'`
videofps=`echo `${videofps:0:2}``
echo "FPS: $videofps"
aspect=`pc $videowidth/$videoheight`
aspect=`echo "$aspect" | tr -s [:digit:]`
echo "Aspect Ratio: $aspect"
#Calculate Video size
VideoSizeCalc
sleep 10
videosize=`pc $videosize*1024`
echo "Videosize = $videosize"

if [[ -e "$original_name" ]]; then
        echo start `date +%H:%M`>$file_name.runtime
        if [[ "$videofps" -eq "59" ]]; then
                nice -n 17 mencoder $original_name -oac copy -ovc xvid -vf decimate=2:1000:1600:.001,scale=960:544 -ofps 24000/1001 -xvidencopts pass=1:vhq=0:me_quality=5:turbo:quant_type=mpeg:aspect=$aspect:max_bframes=0:bitrate=-$videosize -o /dev/null
                #
                nice -n 17 mencoder $original_name -oac copy -ovc xvid -vf decimate=2:1000:1600:.001,scale=960:544 -ofps 24000/1001 -xvidencopts pass=2:quant_type=mpeg:aspect=$aspect:max_bframes=0:bitrate=-$videosize -o $file_name.avi
        elif [[ "$videofps" -eq "29" ]]; then
                nice -n 17 mencoder $original_name -oac copy -ovc xvid -vf pullup,softskip,scale=960:544 -ofps 24000/1001 -xvidencopts pass=1:vhq=0:me_quality=5:turbo:quant_type=mpeg:aspect=$aspect:max_bframes=0:bitrate=-$videosize -o /dev/null
                #
                nice -n 17 mencoder $original_name -oac copy -ovc xvid -vf pullup,softskip,scale=960:544 -ofps 24000/1001 -xvidencopts pass=2:vhq=0:me_quality=5:quant_type=mpeg:aspect=$aspect:max_bframes=0:bitrate=-$videosize -o $file_name.avi
        fi
        echo stop `date +%H:%M`>>$file_name.runtime
        echo "Runtime"
        more $file_name.runtime
fi
exit

NeroAAC in linux

NOTE: Nero recently released a version of their encoder that is linux native, but I haven't updated my script for it since I actually rarely use it now, I've been using dbPowerAmp at work...

Recently Nero released their wonderful AAC encoder for "DOS" (command line app in windows). Since I'm a huge fan of AAC for compressed audio due to its quality I was hoping they'd release a linux version, but as it turns out their windows version was designed to work a-o-k in linux under WINE!

The only caveats I've found is that you need to have the folder where you music ready for conversion is mapped as a drive in Wine. As well, the filenames cannot have any periods in them except for the one that designates the extension (ie this.song.is.good.flac is no good but this song is good.flac is fine), which is an issue I know how to solve with a simple perl rename, but have yet to tackle in the script... Other than that, your good to go.

So what I did, is I wrote a script that will convert any format mplayer supports, as well as APE to M4A. Right now I really only have it setup for WAV, FLAC and APE though, but its pretty easy to add other formats. For mplayer supported formats look at the FLAC functions, for formats that require another decoder to get to WAV look at the APE section. This script can also recursively enter folders, so you can rip a whole lot of CD's (using cdparanoia or EAC under WINE of course!) into seperate folders and run this script from their root and it will go into each folder and convert! how handy!

This site has some great info on the encoder, as well as how to encode directly to M4A when ripping with EAC. This is a good guide to do the same in K3B.

This script has two command line options as of now. First it will allow you to delete the original after a successful encode using -e, or you can specify a specific directory with -d.

This script also has some defined options near the top, EncoderDir=~/.wine/drive_c/Program\ Files/Nero QualityLevel="0.8"

EncoderDir is obviously where your neroAACenc.exe file is, and Quality level is a numerical value for the recording quality setting. I don't like compressed audio and find that 0.8 is a good balance for my ears and my desire to keep file sizes down. This equates to about 300Kbps, which is rather large for even the MP3 format, so feel free to change this value for your needs.

For those that used the old Nero encoder with "Quality Levels", here's a quick conversion chart...

Old Presets Quality Levels
Tape -q=0.0
Radio -q=0.1
Internet -q=0.2
Streaming -q=0.3
Normal -q=0.5
Extreme -q=0.6
Audiophile -q=0.8
Transcoding -q=1.0
 #!/bin/bash
 #
 #
 IFS=$'\n'
 EncoderDir=~/.wine/drive_c/Program\ Files/Nero
 QualityLevel="0.8"
 CURRENTDIR=`pwd`
 directory=$CURRENTDIR
 
 function Main() {
 
         until [ -z "$1" ]
         do
                 echo "Processing parameter of: '$1'"
 
                 if [ ${1:0:1} = '-' ]; then
                         tmp=${1:1} # Strip off leading '-' . . .
                         parameter=${tmp%%=*} # Extract name.
                         if [ "$parameter" = "e" ]; then
                                 echo "Will erase originals upon successful encode!"
                                 opt_e=1
                         fi
                         if [ "$parameter" = "d" ]; then
                                 directory=$1
                                 echo "Directory taken from command line as: $dir
                                 ectory"
                         fi
 
                 fi
 
         shift
         done
         echo "Working directory: $directory"
 
 for dir in $( find -type d )
 do
         cd $dir
         for file in $( find -maxdepth 1 -type f -name '*.flac' -printf '"%f"\n'|
 sort )
         do
                 echo "FLAC format found! Converting \""$file"\"..."
                 rename 's/\.{2,}//' $file
                 file=`echo "$file"|sed 's/\.{2,}//'`
                 basename=`echo "$file"|sed 's/\..*//'`
                 basename=`echo "$basename"|sed 's/\"//'`
 
                 RANDOM='time'
                 TEMPFILE=/dev/shm/neroaac-$RANDOM
                 DecodeMplayerSupported $basename.flac $TEMPFILE
                 EncodeToAAC $basename $TEMPFILE
                 rm -f $TEMPFILE
                 RemoveOriginal $basename flac
                 ls *flac
         done
 
         for file in $( find -maxdepth 1 -type f -name '*.wav' -printf '"%f"\n'|sort )
         do
                 echo "File "$file" already in Wave format, converting to AAC..."
                 basename=`echo "$file"|sed 's/\..*//'`
                 basename=`echo "$basename"|sed 's/\"//'`
                 EncodeToAAC $basename
                 RemoveOriginal $basename wav
                 ls *wav
         done
 
         for file in $( find -maxdepth 1 -type f -name '*.ape' -printf '"%f"\n'|sort )
         do
                 echo "APE format found! Converting \""$file"\"..."
                 basename=`echo "$file"|sed 's/\..*//'`
                 basename=`echo "$basename"|sed 's/\"//'`
                 RANDOM='time'
                 TEMPFILE=/dev/shm/neroaac-$RANDOM
                 DecodeAPE $basename.ape $TEMPFILE
                 EncodeToAAC $basename $TEMPFILE
                 rm -f $TEMPFILE
                 RemoveOriginal $basename ape
                 ls *ape
         done
 cd $CURRENTDIR
 done
         exit 0
 }
 
 function DecodeAPE() {
         inputfile=$1
         outputfile=$2
         nice -n 17 mac $inputfile $outputfile -d
 }
 
 function DecodeMplayerSupported() {
         inputfile=$1
         outputfile=$2
         nice -n 17 mplayer -vc null -vo null -ao pcm:file=$outputfile:fast "$inputfile"
 }
 
 function EncodeToAAC() {
         filebase="$1"
         infile="$filebase".wav
         outfile="$filebase".m4a
         if [ "$2" ]; then
                 infile="$2"
         fi
 
         echo "File base: $filebase"
         echo "TEMPFILE: $2"
         echo "Input File: $infile"
         echo "Output File: $outfile"
         nice -n 17 wine $EncoderDir/neroAacEnc.exe -q $QualityLevel -if "$infile" -of "$outfile"
         if [ $? -eq 0 ]; then
                 echo "Encode Success!"
                 success=1
 #               mv tmp.m4a "$outfile"
         else
                 echo "Encode Failed!"
                 success=0
 #               rm -f "tmp.m4a"
 #               rm -f "tmp.m4a"
         fi
 }
 
 function DiscoverFormat {
         input=$1
 
 
 }
 
 function RemoveOriginal {
         origfile=$1
         extension=$2
         if [ $opt_e -eq 1 ]; then
                 if [ $success -eq 1 ]; then
                         echo "Removing Original file: $origfile.$extension"
                         rm -f $origfile.$extension
                 else
                         echo "Not Removing Original file!"
                 fi
         fi
 }
 
 Main $@