home / blog

Quick photo tidy up

convert from DCIM conventions to date based…

brew install exiftool
exiftool '-FileName<${CreateDate}.jpg' -d %Y%m%d_%H%m%s%%-c -ext jpg *.JPG
exiftool '-FileName<${CreateDate}.mp4' -d %Y%m%d_%H%m%s%%-c -ext mp4 *.mp4
Posted in geek | Leave a comment

Cesium 3D model translation

If you’re using the primitive API rather than the entity API then you do not have easy access to the orientation parameters.

It’s possible to do all this from scratch, but it’s hard work….

var getModelMatrix = function(lon, lat, rotationZ) {
    // 1) create a translation position matrix
    var posMat = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(lon, lat));

    // 2) create a Matrix3 with a given Z rotation
    var rotMat3 = Cesium.Matrix3.fromRotationZ(Math.random() * 360);                        

    // 3) transform the Matrix3 into a Matrix4 with no translation
    var rotMat4 = Cesium.Matrix4.fromRotationTranslation(rotMat3, undefined, undefined);

    // 4) empty matrix to place result in
    var result = new Cesium.Matrix4();

    // 5) multiply position by rotation
    return Cesium.Matrix4.multiply(posMat, rotMat4, result);             
};
Posted in geek | Tagged , | Leave a comment

Install JavaFX Scene Builder 2.0 without local administrator on Windows

Yes, this is possible, by default the javafx_scenebuilder-2_0-windows.msi installs to all users and tries to registry some fonts etc.

This can be avoided by running the following command. This will install a link to the Desktop, when it is run Scene Builder will install, just click Ignore on all the warnings about failed font installation.

msiexec /ju javafx_scenebuilder-2_0-windows.msi
Posted in geek | Leave a comment

Corrupted mythtv database table [SOLVED]

Started seeing “No seektable” when trying to edit recordings – to set cut points…After investigation turned out the table recordedseek in mythconverg was corrupt.

Tried to fix with this but didn’t work.

mysqlcheck --databases mythconverg --auto-repair

Ended up with this solution. Export database excluding bad table, purge database, rebuild and then replay export file on top. Worked perfectly.

# stop mythtv - just in case
sudo service mythtv-backend stop

# backup without bad table - otherwise mysqldump fails
mysqldump --ignore-table=mythconverg.RECORDEDSEEK -p mythconverg > ~/mythconverg-backup.sql

# remove old
mysql -p
> DROP DATABASE mythconverg
> exit
sudo apt-get remove --purge mythtv-database

# replace
sudo apt-get install mythtv-database
mysql -p mythconverg < ~/mythconverg-backup.sql

# start mythtv again
sudo service mythtv-backend start
Posted in geek | Tagged | Leave a comment

Mounting OS X 10.7.5 anonymous share with Ubuntu 14.04 [SOLVED]

This is the final solution. See failed attempts below and error outputs.

# as line in /etc/fstab
//horse.lan/Movies /data/Movies cifs username=guest,password=none,sec=ntlmssp,nounix 0 0

# using mount
sudo mount -t cifs //horse.lan/Movies  -o username=guest,password=none,sec=ntlmssp,nounix /data/Movies

Attempt 1. Fail. Why. mount.cifs not installed by default.

sudo mount -t cifs //horse.lan/Movies  -o guest /data/Movies

mount: wrong fs type, bad option, bad superblock on //horse.lan/Movies,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

Attempt 2 – installed cifs-utils. Fail. Why. Need to use sec option.

sudo apt-get install cifs-utils
sudo mount -t cifs //horse.lan/Movies  -o guest, /data/Movies

mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
# dmesg output
[208134.060470] Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
[208134.060484] CIFS VFS: Send error in SessSetup = -13
[208134.060648] CIFS VFS: cifs_mount failed w/return code = -13

Attempt 3 – added sec option. Fail. Why. Guest option doesn’t work with OS X. Need to use username=guest,password=none.

sudo mount -t cifs //horse.lan/Movies  -o guest,sec=ntlmssp /data/Movies

mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
# dmesg output
[208134.060470] Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
[208134.060484] CIFS VFS: Send error in SessSetup = -13
[208134.060648] CIFS VFS: cifs_mount failed w/return code = -13

Attempt 4 – added manual setting of username/password. Fail. Why. Needs nounix option

sudo mount -t cifs //horse.lan/Movies  -o username=guest,password=none,sec=ntlmssp /data/Movies

mount error(95): Operation not supported
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

# dmesg output
[208260.854805] CIFS VFS: Send error in QFSUnixInfo = -95
[208260.856792] CIFS VFS: cifs_read_super: get root inode failed

Attempt 5 – added nounix option. Win ! Success

sudo mount -t cifs //horse.lan/Movies  -o username=guest,password=none,sec=ntlmssp,nounix /data/Movies

Posted in geek | Tagged | Leave a comment

Ubuntu 14.04 Mythtv box setup notes

# extra repos
sudo apt-add-repository ppa:ehoover/compholio
sudo add-apt-repository ppa:jon-hedgerows/get-iplayer
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

# update
sudo apt-get update
sudo apt-get dist-upgrade

# essentials
apt-get install openssh-server emacs

# static IP address
sudo emacs /etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.5.1.51
netmask 255.255.255.0
gateway 10.5.1.254
dns-nameservers 10.5.1.254

# restore home directories from backup
chown -R mythtv:mythtv ~mythtv
chown -R adam:adam ~adam

# apps
sudo apt-get install mythtv mythweb xmltv-util dvb-apps google-chrome-stable get-iplayer vlc mplayer

# util
sudo apt-get install ethtool nmap git php5-cli cifs-utils

# hardware
sudo apt-get install nvidia-current r8168-dkms

# restore mythtv database
sudo service mythtv-backend stop
mysql -u root -p < backup.sql
sudo service mythtv-backend start
# change mythtv password in database to match /etc/apache2/sites-available/mythweb.conf and ~mythtv/.mythtv/config.xml
mysql -u root -p
update mysql.user set Password=PASSWORD('password') where user = 'mythtv';

# enable auto login
sudo emacs /etc/lightdm/lightdm.conf
[SeatDefaults]
user-session=ubuntu
greeter-session=unity-greeter
autologin-user=mythtv
autologin-user-timeout=0

sudo emacs ~/config/autostart/mythtv-frontend.desktop
[Desktop Entry]
Type=Application
Name=mythtv frontend
Exec=/usr/bin/mythfrontend
Icon=
Comment=mythtv

# Bugfix - stop screen blanking
sudo apt-get remove gnome-screensaver

# configure listings
su mythtv tv_grab_uk_rt --configure
# add update script to crontab
sudo mythtv crontab -e

# remove unnecessary stuff
sudo apt-get remove indicator-bluetooth indicator-keyboard indicator-messages indicator-power  evolution-data-server modemmanager cups-browsed ubuntuone-client cups  unity-lens-video unity-lens-photos unity-lens-music unity-lens-friends unity-lens-files zeitgeist
Posted in geek | Tagged , | Leave a comment

iperf bandwidth testing woes – killing cleanly etc.

When running iperf on Windows platforms it is difficult to shut it down cleanly, without leaving stray child processes – especially if using within Java using ProcessBuilder.

The solution I’ve discovered takes two approaches. Firstly run iperf server using the lesser known -P 1 switch, this causes it to shutdown after the client has connected.

The second issue is stray processes left. It seems that ProcessBuilder.terminate() and ProcessBuilder.terminateForcibly() won’t kill child processes. The way to do it is to send a SIGINT, i.e. a -2 or Ctrl-C in Linux. Unfortunately Windows + Java doesn’t allow such niceties. Fortunately there is an amazing Third Party library called Sigar which will save the day. This keeps your code platform independent.

Sigar sigar = new Sigar();
sigar.kill(12345, "SIGINT");
Posted in geek | Tagged , | Leave a comment

Installing JDK 6, 7, 8 on Windows XP (without admin) [SOLVED]

  • 7zip extract the .exe
  • unzip the tools.zip
  • Create a install.bat in the top level directory
    FOR /R %%f IN (*.pack) DO .\bin\unpack200.exe -r -v "%%f" "%%~pf%%~nf.jar
    
  • Extract the src.zip from an equivalent linux tar.gz distribution as 7zip doesn’t manage to extract this – it’s the same file
Posted in geek | Leave a comment

Mythtv transcode for Android

  • After a number of issues with avconv I switched to ffmpeg. Out of memory (OOM) errors. Non-monotonic timestamp issues, and audio/video sync problems
  • Sometimes mythtranscode can fail. If it does, the recommended way to fix it is to stream copy the .mpg using ffmpeg, replace the original file and try again.
  • Android only supports H264 baseline profiles.
  • 480p works quite nicely on a Samsung S3 screen
  • Built-in mythtv editor for cut-points easy and quick to use – in conjunction with “honorcutlist” option.

Custom job command to invoke

/home/mythtv/bin/transcode.sh "%DIR%/%FILE%" "%TITLE%" "%SUBTITLE%" "%STARTTIMEUTC%" %CHANID%

Script

#!/bin/bash

file="$1"
title=$(echo $2 |  tr -c "[^A-Za-z0-9]" "." )
subtitle=$(echo $3 |  tr -c "[^A-Za-z0-9]" "." )
date=$(echo $4 | perl -pe 's/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/\1.\2.\3-\4.\5/')
nice_title="$title-$subtitle-$date"

DEST="$(dirname $file)/phone"
mkdir -p $DEST

WORKING="$(dirname $file)/working"
mkdir -p $WORKING
cd $WORKING

if [ -f "$DEST/$nice_title.mp4" ]; then
  echo "$DEST/$nice_title.mp4 already exists. Exiting"
  exit
fi

mythtranscode --mpeg2 --chanid $5 --starttime $4 --honorcutlist
if [ ! "$?" == "0" ]; then
 echo "Transcode failed. Attempting to fix with stream copy"
 $HOME/bin/ffmpeg -i $1 -acodec copy -vcodec copy $1.fixed.mpg
 mv $1 $1.backup
 mv $1.fixed.mpg $1
 mythtranscode --mpeg2 --chanid $5 --starttime $4 --honorcutlist
fi;
 
$HOME/bin/ffmpeg -y -i $1.tmp \
 -c:v libx264 -preset slower -profile:v baseline \
 -strict experimental -c:a libfdk_aac -b:a 96k \
 -vf yadif,scale="trunc(oh*a/2)*2:480" -crf 23 -r 25 \
 "$nice_title.mp4"

mv -f "$nice_title.mp4" $DEST
Posted in geek | Leave a comment

non monotonically increasing dts error with mythtranscode [solved]

I found the error when processing the output from mythtranscode with avconv.

invalid non monotonically increasing dts to muxer in stream 1

I fixed it with a stream copy using mencoder

mencoder "input.mpg" -oac copy -ovc copy -o output.mp4

The same technique with avconv did not work, it crashed with the same non monotonic error.

avconv -y -i "input.mpg" -c:v copy -c:a copy output.mp4
Posted in geek | Leave a comment