Saturday 11 October 2008
Nuvexport for mythtv
You can configure MythTv to automatically transcode recordings to other formats (iPod MP4 etc).
If you're using ubuntu hardy 8.04 (or some other package based distros) then you may need to compile ffmpeg from source to get xvid and other support.
https://wiki.ubuntu.com/ffmpeg is great, but fails to mention you need to enable support for mp3 with the option --enable-libmp3lame when you're running configure.
If you do not, you'll get the following error when running nuvexport. This refers to the audio codec mp3 not being supported.
Error while opening codec for output stream #0.1
To check what is supported run ffmpeg -formats. The output is a little cryptic. D and E refer to decode and dencode support. Also, don't confuse file (container) formats with the actual codecs...
Use mythweb (or the mythtv interface) to edit the entry "User job 1". This will be called after each file is recorded and transcoded. Mythweb -> settings -> mythtv -> settings table -> user job 1. Read for full details, including the need to restart myth backend etc.
/home/mythtv/mythexport.sh %FILE
Contents of /home/mythtv/mythexport.sh
Note you'll need ubuntu package mpeg4ip-server to get the mp4creator tool.
#!/bin/bash # # Simple wrapper to convert then upload # mythexport# DEST="user@host:/file/path/foo/bar/etc" file="$1" if [ "$file" = "" ]; then echo "Usage `basename $0` " exit fi; # create a temporary directory and change to it dir=`mktemp -d` cd $dir # transcode the video nuvexport --profile adam --input $file # Make the MP4 file playable before load completion # i.e. without this the quicktime plugin (or other player) # will download the entire file before playing it mp4creator -hint=1 *.mp4 mp4creator -hint=2 *.mp4 mp4creator -optimize *.mp4 # upload scp -l 512 *.mp4 $DEST # clean up rm *.mp4
New profile in /etc/nuvexportrc
<profile::adam>
underscores=yes
filename=%m - %t - %s
date=%Y-%m-%d %H:%M
vbr = yes
multipass = yes
export_prog = ffmpeg
mode = mp4
width = 320
height = auto
a_bitrate = 96
v_bitrate = 400
</profile::adam>
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Tuesday 7 October 2008
Wake on LAN issues : RT 8111 / 8168B
There is a problem with the drivers that support this chipset
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)
Linux version 2.6.24-18-386
First, "upgrade" to the realtek supplied module (r8168), and blacklist/remove r8169
This taken from http://ubuntuforums.org/showthread.php?t=723569
1 - Downloaded current driver from :
http://www.realtek.com.tw/downloads/...&GetDown=false
2 - Unpacked on the Desktop
3 - $ sudo mv r8168-8.004.00 /usr/src
4 - $ cd /usr/src/r8168-8.004.00
5 - $ sudo make clean modules
6 - $ sudo make install
7 - $ sudo depmod -a
8 - $ sudo insmod ./src/r8168.ko
9 - $ lsmod -a | grep 8186 #just to check it was there
10 - $ cd /etc/modprobe.d
11 - $ sudo touch blacklist-network
12 - $ vi blacklist-network # add "blacklist r8169" to the file
13 - $ sudo update-initramfs -u #to make the change permanent
14 - reboot
15 - ethtool -i eth0 #to see new driver assigned
Next, modify your start-up scripts so that the interfaces are not shutdown. This is because there is a bug in the shutdown routine of the module which causes the wake-on-lan state to be reset.
- Comment out ifdown where ever it occurs in files in /etc/init.d/networking
- Remove the "-i" option from any calls to halt in /etc/init.d/halt
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Wake on LAN issues: Speed touch 780
To get WOL to work over the Internet (through a router), you need to create a forwarding rule that directs UDP packets at the machine you wish to wake. Note TCP will not work because the connection can never be formed without an active TCP stack on the receiving machine (which is powered off!!).
i.e. external port X on your router directs to port X on the machine on your network. Low level hardware detects the 'magic packet' in hardware and generates a wake up event.
Unfortunately, you can't just use a "SpeedTouch 780" for this out-of-the-box. Tinkering is required.
Following taken and corrected from http://bbs.adslguide.org.uk/showthreaded.php?Cat=&Board=beunlimited&Number=2984217&page=3&view=expanded&sb=1&o=0
1.) Telnet 192.168.1.254 (or wherever it lives) and login with your normal username and password.
2.) Type ip.
3.) Type arplist, this should print out your routers current arp table which should contain an entry for your machine.You need to delete this dynamic entry and add a static one so you need to take a note of the Interface, IP-Address and Mac address.
3b) Physically disconnect the machine you're trying to set up the route to and continue following these instructions from another computer. Otherwise you'll not be able delete the entry, it will keep appearing.
4.) Type arpdelete, enter "LocalNetwork" for intf, your machine's ip for ip and your machine's mac address for [hwaddr].
5.) Type arpadd and enter the same parameters above.
6.) Type arplist again, your machine should be back in the table but the entry in the type column should now read static instead of dynamic.
7) Reconnect the target machine
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Friday 4 January 2008
MythTv - more madness
Update to ubuntu 7.10
Problem:
Can't get Terratec Cinergy XS DVB tuner USB stick to work.
Device is recognised but dvbdate does not work, channels cannot be viewed or recorded with mythtv
Cause:
Using USB 1.1 support by disabling ehci_hcd. ehci_hcd is required for USB 2.0. note the message in dmesg
em28xx: setting up device on a USB 1.1 bus em28xx: your device won't work properly when em28xx: not attached to a USB 2.0 highspeed bus
Solution
Re-enable ehci_hcd. Perhaps you added it to /etc/modprobe.d/blacklist? If so remove it.
Now lsusb doesn't list the device. Just blank entries, but you're sure it's plugged in. What's going on ????
You need to add this to your /etc/fstab
usbfs /proc/bus/usb usbfs auto 0 0
Now force a mount:
mount /proc/bus/usb
Now, you can reboot or force a reload of everything with something like this:
lsusb /etc/init.d/mythtv-backend stop sleep 1 rmmod em2880_dvb rmmod em28xx rmmod uhci_hcd rmmod ehci_hcd rmmod usbcore rmmod tuner rmmod tveeprom rmmod xc3028_tuner modprobe usbcore modprobe ehci_hcd #modprobe uhci_hcd modprobe usbcore modprobe em28xx modprobe em2880_dvb modprobe xc3028_tuner /etc/init.d/mythtv-backend start lsusb dvbdate
dvbdate should return the current date from the "air". This is a good test of full functionality of a dvb tuner.
dmesg should show something like this instead
em28xx: device is attached to a USB 2.0 bus
Further reading
Official em28xx module support
https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.22/+bug/88746
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Saturday 10 November 2007
Converting mythtv recorded files
In order to use TV programs recorded by mythtv with a video editor such as Final Cut Pro some conversion needs to be done.
The first step is to fix the video using mythtranscode. Raw mpeg TS files recorded by mythtv will only play with mplayer/VLC but crash most other programs
mythtranscode --mpeg2 --infile input.mpg --outfile output.mpg
However, mythtranscode appears to loose the audio stream!
So run this to extract the audio from the original file
mplayer -vo null -hardframedrop -ao pcm:file=soundtrack.wav input.mpg
Now output.mpg and soundtrack.wav can be loaded into Final Cut Pro and you can edit away. This does not deinterlace the file though and various deinterlace filters in final cut do not appear to work.
Another way possibly better way to convert the files is use nuvexport. This has the disadvantage of quality loss of re-encoding the files. It does do de-interlacing. nuvexport also seems tied into mythtv, i.e. you can't give it arbitary mpeg files to work with as it queries the mythtv database to lookup the file.
nuvexport-xvid --transocde --deinterlace --quantisation 1 --a_bitrate 192 --v_bitrate 5000 --nice 10 --input=1001_20071025193000.mpg
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Ubuntu gutsy gibbon update fstab problems
Extra partitions can no longer be accessed via standard /dev/sdxn (x=a,b,c etc, n=0,1,3 etc) references, instead /dev/mapper/sdb5 style references should be used.
If one tries to mount a drive via /dev/sdxn a rather confusing message is displayed.
mount: /dev/sdb5 already mounted or /mountpoint busy
This implies the volume is already mounted, which it is not.
The symlinks in /dev/disk/by-uuid (used if you use UUID references in fstab) also point to /dev/sdxn references.
Interestingly additional drives added after startup such as external USB drives are accessible via /dev/sdxn references and not /dev/mapper/sdxn.
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Sunday 21 October 2007
uhci_hcd and ehci_hcd
Hmmm. Not sure what's going on here.
lsusb sometimes doesn't show the usb tuner stick (Terratec Cinergy XS T DVB tuner) that is obviously plugged in...
I discovered by removing and reinserting various kernel modules it started working again (showing it was not just a loose connection).
What is the difference between the host controller modules uhci_hcd and ehci_hcd and should both be inserted at once?
I found the card started working after just reinserting the uhci_hcd module suggesting the other one is unnecessary AND causes problems.
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Saturday 20 October 2007
Random
Removing accents from French text.
This is the only way I've found to do it so far. Any better ideas?
cat input.txt | tr "\350\351\352\340\341\342\343\344\345\362\363\364\365\366\371\372\373\374" "eeeaaaaaaooooouuuu"
Note tr \xxx is octal.
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Saturday 30 June 2007
Blair out
My "No war, blair out" t-shirt suddenly became fashionable.
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Saturday 28 April 2007
Benchmark drive speed
#!/bin/bashpath=$1
size=1000
if [ $# -ne 1 ]; then
echo "Usage: `basename $0`"
exit 1
fi# Make file N MB large, time it to write
t1=`date +%s`
dd if=/dev/zero of=$path count=$(( 1024*1024*$size / 512 )) bs=512 &> /dev/null
t2=`date +%s`echo -n "Write speed MB/s :"
echo "$size / ($t2 - $t1)" | bc# Read from file created in previous step, time it to read
t1=`date +%s`
dd if=$path of=/dev/null count=$(( 1024*1024*$size / 512 )) bs=512 &> /dev/null
t2=`date +%s`echo -n "Read speed MB/s :"
echo "$size / ($t2 - $t1)" | bc
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Or you could use /sbin/hdparm -tT ;)
Bluetooth remote not working in feisty faun - solved
This happened because I updated from edgy ubuntu distribution which contained a previous version
/etc/init.d/bluetooth.dpkg-inst # new version
/etc/init.d/bluetooth # old version
Copy the new file over the old one
and call
/etc/init.d/bluetooth restart
The problem was caused because the old version silently failed when it could not find the sdpd binary which has now been incorporated into the hcid binary and activated by hcid -s
source/kdebluetooth/+bug/96916
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Tuesday 24 April 2007
Fixing My Book Western Digital boot up problem
Currently the message
"DISK BOOT FAILURE, INSERT SYSTEM DISK AND PRESS ENTER" is displayed if i attempt to boot with the disc attached (via USB2.0)
The BIOS is at fault here, the BIOS ID is "02/24/2004 KT600 8237 6A6LYA1GC-14"
Turning off USB does not work as ubuntu does not re-enable it rendering the computer without USB.
BIOS updates from motherboard manufacturer abit.
Reflash BIOS with update, remember how to use DOS. Boot from CD floppy discs are so 1990s.
BIOS ID now reads KT600 8237 6A6LYA1GC-20
Message reads the same :(
"DISK BOOT FAILURE, INSERT SYSTEM DISK AND PRESS ENTER"
Next strategy:
Install grub on the external hard disc and have it chain load the internal disc
run grub-install
"Error /dev/hdX does not have any corresponding BIOS drive and Solution"
This most likely means that the device needs adding to /boot/grub/device.map
Mine now looks like this, the first two lines are my existing two internal SATA drives, the last is the removable drive.
(hd0) /dev/sda (hd1) /dev/sdb (hd2) /dev/sdc
mkdir foo # make a temp mount point
mount /dev/sdc1 foo # mount first partition of the disc
grub-install --root-directory=foo /dev/sdc # install grub
# run grub to configure the stage 1 loader
grub<
grub< root (hd2,0)
grub< setup (hd2)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd2)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd2) (hd2)1+15 p (hd2,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.
Actually scratch that, it's way easier just to copy across the contents of /boot on the internal to the external drive, maybe only include your current drive, and just do
grub< root (hd2,0)
grub< setup (hd2)
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
Wednesday 21 February 2007
Terratec cinergy T USB XS linux module
Follow instructions on this site. Note that you need linux source installed. All this means is that you should have /usr/src/linux pointing at the same version of the source as your kernel (uname -a). If you're using ubuntu or other distribution with ready made kernels there is no need to install a kernel from source, just download, copy config from /boot/ to .config in source and do a make all modules.
Also note that there are two source repositories mentioned at the video for linux (V4L) site. Only the first of these contains the source for the em2880_dvb module.
- http://linuxtv.org/hg/~mrechberger/v4l-dvb
- http://linuxtv.org/hg/v4l-dvb
0ccd:0043 TerraTec Electronic GmbH
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
A better mousetrap
Today i finally outwitted our resident mouse, or should i say; one of our resident mice! Here's the lego trap that finally worked. This was trap mkIII, a conventional non-fatal trap box with sprung snapping lid with very lightly triggered falling floor. The bait goes on the floor, the mouse climbs in, the lid comes down, wo ha hah ha hhhaaaa.


Other failed methods included
- Using a remote UPnP camera in the kitchen, monitoring from upstairs, then coming down to try and take on the mouse in hand-to-hand combat. Seemed a good idea after a few drinks.
- mkI - simply a sandwich box with a trap door, but it managed to jump out.
- mkII - similar idea, but using a waste-paper bin instead, again the mouse alluded the trap door and ate all the bait
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks
perhaps the bright colours helped to attract the little bastard!
I hope you took him over a mile away..
Tuesday 30 January 2007
Auto scp upload directory script
# crontab line * * * * */usr/bin/webup -l 200 /local/dir user@host:/remote/dirEnd result drop a file into a local folder, and it will be uploaded to your website, ideal for uploading loads of media, files are loaded up sequentially with optional upload rate limiting.
#!/bin/bash
# Description
# Upload files from a directory to a host using scp
# (hopefully using public/private key pair auth)
# Files will be moved to ./complete subdirectory. So
# folder can be used across samba etc for easy upload
# to your webhost as drag and drop folder
#
# Usage
# webup [-l limitkbps] localfolder user@host:remotefolder
#
# Warning
# Be aware this script could upload a php pl asp or other
# server side script which could then be run via apache
# - Consider restricting access to localfolder
# or remote folder (i.e. chmod, .htaccess respectively)
#
# Requires
# - Some host to upload with scp
# - scp available
# - key pair setup for SSH so there is no password prompt
#
# Uses
# PID file - /var/run/webup
#
# Suggested usage
# Trigger this from a crontab
# Example crontab line, check every minute
#
# * * * * */usr/bin/webup -l 200 /local/dir user@example.com:/remote/dir
#
pidf="/tmp/webup.pid"
default_uplimit_kbps="200"
sub=""
uplimit=""
while getopts l:s: name
do
case $name in
l)
uplimit="$OPTARG";;
s)
sub="$OPTARG";;
?)
echo "Usage `basename $0` host localdir remotedir [limit_kbps]"
exit 2;;
esac
done
shift $(($OPTIND - 1 ))
# Save parameters
localdir=$1
localdircomplete=$localdir/complete
localdirlog=$localdir/log.txt
uhd=$2
localfile=$3
if [ "$sub" = "upload" ]; then
echo "scp -r -l $uplimit "$localfile" $uhd" >> $localdirlog
scp -r -l $uplimit "$localfile" $uhd >> $localdirlog
return=$?
# Only copy files which copied without fault
# to complete
if [ "$return" -eq 0 ]; then
mv "$localfile" "$localdircomplete"
fi;
else
if [ ! -d $localdir ]; then
echo "Local directory $localdir does not exist. Exiting";
exit 1;
fi;
# Make complete directory if does not already exist
mkdir $localdircomplete 2> /dev/null;
# Save optional limit
if [ "$uplimit" == "" ]; then
uplimit=$default_uplimit_kbps
fi
if [ -f $pidf ]; then
echo "Instance `cat $pidf` already running. Exiting"
exit 1
fi;
# create run lock
echo $$ > $pidf
# Find all files in localdir and pass to self for
# upload
find $localdir -mindepth 1 -maxdepth 1 -name "*" | grep -v "$localdircomplete" | grep -v "$localdirlog" | xargs -I{} $0 -l $uplimit -s upload $localdir $uhd "{}" \;
# release run lock
rm -f $pidf
fi
Comments are disabled, I'm tired of cleaning up after spam attacks. If you desperately wish to contribute email me at blog at adamish dot com. Thanks