Format Conversion Scripts

Format Conversion scripts

WMA to MP3

I created this script to go through all *.wma files in a directory and convert them to mp3 files and then delete the wma files. I works great for my mp3 play that does not support wma. It takes the wma files and converts them to wav then converts them to mp3. It uses mplayer and lame to do the work.

#!/bin/bash
#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -ao pcm -vc dummy "$i" && lame --preset 128 audiodump.wav -o "`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
#Delete audiodump.wav
rm audiodump.wav

ffmpeg

If you need to transcode from one format to another I have struggled to get it working correctly the fastest / best program I have used is ffmpeg. I’ll document some of my steps here to make the correct ffmpeg setup.

To display all codec’s / supported formats type

ffmpeg -formats

To convert from a file to avi type this:

ffmpeg -i inputfilename.mpg output.avi

Fixing Transcodes and nuvexports

Use replex to fix them

It turns out that the raw stream isn’t quite compatible with the DVD standard. There is apparently a small glitch in some of the hardware encoding done by the chip on my PVR-150 encoder. As such, another round of processing needs to be done to detect these glitches and patch them. A command-line tool has been written which does just that: replex.

Here’s the syntax:

$replex -t DVD -k -o Out.mpg In.mpg

The above command would take an input file In.mpg, generated by nuvexport, and create a new, fully DVD compatible file Out.mpg. A slightly fancier command can be done to process all the .mpg files in a particular directory:

$find . -name '*.mpg' -print0 | xargs -0 -i replex -t DVD -k -o '{}'.replexed '{}'

This will take all input files as ending with the .mpg file extension, process them, and generate outputs that have the same base name but with ‘replexed’ appended as the new file extension.

MythTV Keybindings

Clear Key Bindings

Once and a while I really screw up my key bindings on my system. When this happends it’s nice to flush the key bindings from the database. From the command line type:

echo "delete from keybindings ;" | mysql -u mythtv -pmythtv mythconverg

Backup Key Bindings

It never hurts to backup your keybindings once and a while before your about to change them. From the command line type:

mysqldump -u mythtv -pmythtv --databases mythconverg --table keybindings > keybindings.sq

Restore from Backup of key bindings

Backups are not very good unless you can restore from the backup. Use the following command to restore a backup.

mysql -u mythtv -pmythtv mythconverg < keybindings.sql

Delete old recordings on MythTV

About once a year I have to delete a history of old recorded shows on my Myth box so I can record the show again.   You can do this via the frontend but I prefer to hack it out of the database.  All this information is stored in the oldrecorded table inside your myth database.   Before you start deleting make sure you have the correct information by using select statements (for example Stargate Atlantis)

SELECT * FROM oldrecorded WHERE title = ‘Stargate Atlantis’

You can also use wildcards to help locate the title:

SELECT * FROM oldrecorded WHERE title LIKE ‘Stargate%’

Once you are sure your select statement has narrowed down to an exact need then you can delete it

DELETE FROM oldrecorded WHERE title = ‘Stargate Atlantis’

And that’s it 🙂

WMA to MP3 on Linux

WMA to MP3

I created this script to go through all *.wma files in a directory and convert them to mp3 files and then delete the wma files. I works great for my mp3 play that does not support wma. It takes the wma files and converts them to wav then converts them to mp3. It uses mplayer and lame to do the work.

#!/bin/bash
#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -ao pcm -vc dummy "$i" && lame --preset 128 audiodump.wav -o \
"`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
#Delete audiodump.wav
rm audiodump.wav 

MythTV Automatic Email of new Pilots Report

Over the years I have written a ton of reports for MythTV.  This particular report sends an email using an smtp email account with all the new shows with pilot as a subtitle.  This allows me to quickly scan new shows for things I want to record.  I wrote it in php since most Myth systems are running php for MythWeb.    I know it’s not the cleanest code but it works for me.  I have bolded items that you need to customize for your environment.  I load it in as a weekly cron job and it’s good to go:

new_pilot.php

MythTV Automatic Email of TV pilots

Over the years I have written a ton of reports for MythTV.  This particular report sends an email using an smtp email account with all the Shows with pilot as a subtitle.  This allows me to quickly scan new shows for things I want to record.  I wrote it in php since most Myth systems are running php for MythWeb.    I know it’s not the cleanest code but it works for me.  I have bolded items that you need to customize for your environment.  I load it in as a weekly cron job and it’s good to go:

all_pilots.php

Mythdora Upgrade from .21 to .22 problems with mp4 playback

I have been having stability problems with my Myth backend and primary front end so I went for a upgrade.

yum upgrade \*myth\*

This worked perfectly except MP4’s would not play anymore.  Normally this would not be an issue except almost everything I have is in MP4 (H264) with (AAC) audio.    It took a little time to find the solution and I messed with all kinds of menu’s and such in the end it turns out a symlink is missing:

ln -s /usr/lib/libfaad.so.0  /usr/lib/libfaad.so

Then they magically worked.

The upgrade also changed a log of functionality which can be a learning curse read up before you upgrade.

MythVideo Transition Guide