Remote access to your PC/Mac – the easy way

I’ve had to help my friends, many, many times with their computer problems and I’ve used a tool for my years now that enables me to connect to their computers remotely to assist them. It’s almost impossible for the average user to explain in words what is occurring, so have the ability to remotely connect and see their desktop is priceless. This works on PC and Mac.

I use a program called Team Viewer, which is free for personal use and this is how I use it.

Step 1: I send an email to the person requiring help with this link http://download.teamviewer.com/download/TeamViewerQS_en.exe

This is a standalone client for team viewer that doesn’t require administration rights to run. Of course this is also assuming that the users is able to use their email, download and run the executable.

Step 2: When they run the program it will provide them with an ID and password. Ask them for this information.

TV

Step 3: At your end you should download and install the team viewer program.

http://download.teamviewer.com/download/TeamViewer_Setup_en.exe

Step 4: Once you run TeamViewer you just pop in the ID and password from step 2 and TeamViewer should bring up the remote desktop.

Simple and effective!

If you have some people you are always providing support too, you can also permanently install TeamViewer and set it up for automatic and unattended setup. This is also handy if you want to connect to your own PC remotely for some reason.

 

 

 

Fixing mythvideo missing coverart and metadata

I’ve never managed to get mythvideo to find cover art and metadata for all of my videos, but I have discovered that a lot of it has to do with the naming of your video files. So I thought I would share some tips and tricks for getting metadata and cover art to work on mythvideo.

1. Understand the file naming conventions found here –> http://www.mythtv.org/wiki/MythVideo_File_Parsing. Originally I had all of my files named in this format:

filename.(year).mp4

I found that the tmdb.py metadata script used by mythtv didn’t use the date to help isolate the video and hence there were too many videos returned from themoviedb.org and  mythvideo didn’t know which one to choose. By removing the brackets, I found that I fixed heaps of videos immediately, as the date helped to resolve multiple returned results.

eg. Back.to.the.future.(1985).mp4 would return 9 possible results.

But  Back.to.the.future.1985.mp4 would only return 1.

2. Use the correct spelling – I found quite a few videos with incorrect spelling. This cause the metadata not to be found.

Eg. How.to.loose.a.guy.in.ten.day.2003.mp4 should be How.to.lose.a.guy.in.ten.day.2003.mp4

Also watch for words spelt differently in different countries.

eg. Dont.tell.mum.the.Babysitters.Dead.1991.mp4 should be Dont.tell.mom.the.Babysitters.Dead.1991.mp4

3. Numbers are not well liked. I had heaps and heaps of trouble trying to work out these sort of filenames. I think there is a limitation with the tmdb.py script used in mythvideo as themoviedb.org site resolved these fine but not mythvideo.

10000.BC.2008.avi
2010.1984.avi
28.Days.Later.2002.mp4
50.First.Dates.2004.avi
127.Hours.2010.avi
2012.2009.mp4
300.2006.m4v
88.Minutes.2007.avi
2001.A.Space.Odyssey.1968.avi
3:10.to.Yuma.2007.mkv

I found the easiest way to deal with these file names was to put the number inside a set of single quotation marks ‘ ‘. So would get the following instead.

‘10000’.BC.2008.avi
‘2010’.1984.avi
’28’.Days.Later.2002.mp4
’50’.First.Dates.2004.avi
‘127’.Hours.2010.avi
‘2012’.2009.mp4
‘300’.2006.m4v
’88’.Minutes.2007.avi
‘2001’.A.Space.Odyssey.1968.avi
‘3:10’.to.Yuma.2007.mkv

4. Punctuation can cause issues. I found some of my files names with punctuation can fail to find metadata. The simple fix is to remove the offending punctuation.

eg. Dirty.Dancing.-.Havana.Nights.2004.avi –> Dirty.Dancing.Havana.Nights.2004.avi

 

Merge multiple mp4/m4v files

Here is a simple way to merge two mp4/m4v files into one:

MP4Box -cat file1 -cat file2 -new outputfile

It will go off and read the video and audio for the first file and then the second and then produce a single file.
Here is an example where I wanted to join Part 1 and Part 2 of Ben Hur into 1 file.

$ MP4Box -cat "Ben.Hur.1959.Part.I.mp4" -cat "Ben.Hur.1959.Part.II.mp4" -new Ben.Hur.1959.mp4
 IsoMedia import - track ID 1 - Video (size 718 x 374)
 IsoMedia import - track ID 2 - Audio (SR 48000 - 2 channels)
 IsoMedia import - track ID 3 - VobSub (size 720 x 576)
 IsoMedia import - track ID 4 - media type "text:text"
 IsoMedia import - track ID 1 - Video (size 718 x 374)
 IsoMedia import - track ID 2 - Audio (SR 48000 - 2 channels)
 IsoMedia import - track ID 3 - VobSub (size 720 x 576)
 IsoMedia import - track ID 4 - media type "text:text"
 Saving to Ben.Hur.1959.mp4: 0.500 secs Interleaving

If you don’t have the MP4Box command available on your system you will need to do the following to install it.

$ sudo apt-get install gpac

Turn mythtv recordings into mp4 files

This piece is a work in progress, but I figured I should publish it slowly as I continue to add to it, as it might help people, even though it is not quite working yet. I’ve had it working in the past, but it’s not quite working on my setup yet.

I’ve spent a lot of time playing around with mythtv recordings to try and keep them for later viewing in a format that is transferable to other devices, players etc. I have found x264 encoding in an mp4 container to work quite well – especially for transferring to my ipad or iphone for viewing.

In this guide I re-encode my mythtv nuv files into mp4 x264 files and save them into my videos for viewing through mythvideo. I use the mythnuv2mkv.sh script which I have found to be the best script available for doing the re-encoding – though if you know of a better script, feel free to point it out.

1. Configure mythnuv2mkv script on your system 

Setup a custom job utilising the mythnuv2mkv.sh bash script. You will first need to get it here –> http://www.mythtv.org/wiki/Mythnuv2mkv

I suggest you place it somewhere on your system where all users can access. I’ve put mine in /usr/local/bin/
Make sure you chmod 755 to ensure it is executable.

2. Install dependencies for the mythnuv2mkv script to work

Install the dependencies required for it to work. I suggest installing all of the mp4 and mkv dependencies.

$ sudo apt-get install mplayer mencoder wget imagemagick x264 faac faad gpac vorbis-tools mkvtoolnix

3. Customise the script to your liking

There a quite a few options to consider for the mythnuv2mkv script. The options are stored in a seperate file named mythnuv2mkv.cfg which resides in the same directory/folder as the mythnuv2mkv.sh script. Here is a copy of what I have to help you.

4. Setup a user job on mythtv.

You will need to setup a user job in order to call the mythnuv2mkv.sh script from mythtv. The easiest way is to use mythweb to do this. I have a previous post on this here — Adding a mythtv job using mythweb

Using this guide, make the following changes to these variables and save them .

 JobAllowUserJob1 = 1
 UserJob1 = /usr/local/bin/mythnuv2mp4.sh --jobid=%JOBID% --quality=med --copydir=/media/videos/newly.exported --chanid=%CHANID% --starttime=%STARTTIME%
 UserJobDesc1 = Convert to mp4

Restart mythtv-backend in order to enact the changes. Remember that if you do this, you can cause programs that are being recorded to be interrupted. I suggest that if you have anything recording that you wait until nothing important is recording before restarting mythtv-backend.

5. Test the user job.

Now that you have the script and user job added to mythtv, you just need to find a recording and test it.

Adding a mythtv job using mythweb

Here are some simple instructions on how to setup a job within mythtv using the mythweb plugin. The mythtv site has some information on user jobs, but not very descriptive on how to setup through mythweb.

  1. Go to your mythtweb web page – wherever that may be (e.g. http://127.0.0.1/mythweb)
  2. Click on the settings icon
  3. Choose the setting for mythtv – you should now have a list of settings similar to this. Make sure you have the “Edit settings for: -All Hosts-” is selected.

Screen-Shot-2012-07-22-at-12.36.56-PM
4. Within the table you should find 3 fields that you need to change in order to get a job configured. These are :

  • JobAllowUserJob1 – this needs to be set to 1 for on (as opposed to 0 for off)
  • UserJobDesc1 – this is a simple description for the job. Whatever you want to make it.
  • UserJob1 – this is the command you want to run itself (e.g. /usr/local/bin/mythnuv2mp4.sh –jobid=%JOBID% –quality=med –copydir=/media/videos/newly.exported –chanid=%CHANID% –starttime=%STARTTIME)

You can essentially run whatever script you like as a user job. Go to this page on the mythtv site for a description on the job arguments. The example I have used is from my previous blog on setting up the mythnuv2mkv script which is quite useful for exporting TV recordings for later use. Click here for more information.

5. Now once you make the changes you want, make sure you press the “Save” button at the bottom of the form to commit the changes.

6. In order to use the new job, you will need to restart mythtv.

$ /etc/init.d/mythtv-backend restart
OR
$ service mythtv-backend restart

The job should now be ready to go. All you need to do is highlight the TV recording you want to run the job on press the menu button on your remote and you should see under the job options section your job description. Select it and it should run. Under system status you can view the job status.

I hope that helps.

Joining two (or more) avi files together with mencoder

Have you ever needed to join two avi (or more) files together to create one avi file? Well there is an easy way to merge them together using mencoder. This also assumes that the files are actually the same size, in the same codec etc.

Make sure you are in the same directory as the files you want to join

Use the following command to join the files.
mencoder -forceidx -ovc copy -oac copy -o outputfile.avi firstfile.avi secondfile.avi

Obviously you would replace outputfile.avi, firstfile.avi and secondfile.avi with whatever is appropriate what you are doing.
Mencoder will go off and join the two files. It should do this really quickly as this command is not re-encoding the files, just putting them together. It should look something like this:


$ mencoder -forceidx -ovc copy -oac copy -o new_file.avi 1.avi 2.avi
MEncoder svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlayer Team
success: format: 0 data: 0x0 - 0x2bcbd408
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
Generating Index: 99 %
AVI: Generated index table for 158686 chunks!
VIDEO: [XVID] 624x256 12bpp 23.976 fps 1319.0 kbps (161.0 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:624x256 fps:23.976 ftime:=0.0417
videocodec: framecopy (624x256 12bpp fourcc=44495658)
audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=0 B/s=56000 sample-1)
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:3308.5s 79325f (99%) 4307.40fps Trem: 0min 700mb A-V:0.000 [1318:448]
Incomplete stream? Trying resync.
Pos:3309.3s 79345f (100%) 4301.24fps Trem: 0min 697mb A-V:0.000 [1318:447]
success: format: 0 data: 0x0 - 0x2bb43de0
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
Generating Index: 99 %
AVI: Generated index table for 150239 chunks!
VIDEO: [XVID] 624x256 12bpp 23.976 fps 1414.9 kbps (172.7 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:624x256 fps:23.976 ftime:=0.0417
videocodec: framecopy (624x256 12bpp fourcc=44495658)
audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=0 B/s=56000 sample-1)
Pos:4587.6s 109994f (46%) 3049.37fps Trem: 0min 2201mb A-V:0.071 [1419:448]]]
ODML: Starting new RIFF chunk at 1023MB.
Pos:6442.5s 154466f (100%) 3326.00fps Trem: 0min 1395mb A-V:0.071 [1365:447]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Video stream: 1365.588 kbit/s (170698 B/s) size: 1099729277 bytes 6442.526 secs 154466 frames
Audio stream: 448.000 kbit/s (55999 B/s) size: 360772608 bytes 6442.368 secs

If you are wondering what the mencoder options are, here is a basic run down.

-forceidx – this forces the regeneration of the index table for the video. Apparently it’s needed.
-ovc copy – this tells mencoder to copy the video codec exactly as per the input file(s). In other words don’t re-encode it.
-oac copy – this tells mencoder to copy the audio codec exactly as per the input file(s). Again, in other words don’t re-encode it.

Oh, and in case you are wondering if you have more than two files you just add more on to the end of the command. Example:

mencoder -forceidx -ovc copy -oac copy -o outputfile.avi firstfile.avi secondfile.avi thirdfile.avi forthfile.avi

Also, if you don’t actually have mencoder, you can install it by running this command:

sudo apt-get install mencoder

References: http://www.mplayerhq.hu/DOCS/HTML/en/index.html

Install Digital Now Quad Card on mythbuntu 10.10 64-bit

I found the Digital Now Quad Tuner card worked great in my mythtv server and was well worth the $199 AUD price tag. In fact, it’s probably the best tuner I have ever used with mythtv. However I did have to do a few things to get it to work, as it doesn’t work straight out of the box – at least on mythbuntu 10.10 64-bit with kernel 2.6.35-28. It doesn’t work on 11.04 on kernel 2.6.38-8. I googled around and put together the following to get it to work.

First of all you need to install all sorts of packages that are needed to compile the drivers. I’m not sure whether you need all of these, but if you install these you should be okay.

I did everything below as root.

apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile kernel-wedge
apt-get install git-core libncurses5 libncurses5-dev
apt-get install libelf-dev libdw-dev asciidoc binutils-dev

do uname -a to get the current kernel version you are using.

root@clumix:~# uname -a
Linux clumix 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:39:03 UTC 2011 x86_64 GNU/Linux

now install the headers for that version. Example:

apt-get install linux-headers-2.6.35-28-generic

wget http://www.medianow.com.au/data/Linux4Quad2.zip

unzip the package by running this

unzip Linux4Quad2.zip

You should then have a directory called “Linux4Quad” – change to this directory

cd Linux4Quad

Untar the tar-bzip file in this directory.

tar jxvf digitalnow-quad.tar.bz2

You should now have a directory called “digitalnow-quad” – change to this directory.

cd digitalnow-quad

And now there is yet another tar-bzip file to uncompress. Don’t run the install.sh script as it won’t work.

tar jxvf v4l_dvb_digitalnow.tar.bz2

Now you need to modify the “.version” file under the “v4l” directory to match your kernel version.

VERSION=2
PATCHLEVEL:=6
SUBLEVEL:=35-28
KERNELRELEASE:=2.6.35-28-generic

Now you need to compile the software and this will take time to complete depending on your PC specs. I found on a quad core machine it took about 10 minutes. Run this from the “digitalnow-quad” directory.

make

Once this completes successfully you need to run this to install:

make install

then reboot the machine.

I found that for some reason my MCE remote stopped working. I suspect the mceusb module was being loaded incorrectly due to the installation of a custom v4linux drivers (or something silly). So I edited /etc/modprobe.d/blacklist.conf

and add

blacklist mceusb

rebooted again and all worked fine.

Note: you may find that if you update you kernel that you will need to recompile and reinstall these drivers in order for the card to work again.

restart mythfrontend using your remote control and irexec

mythfrontend sometimes freezes on me. So I configured a button on my remote control to enable me to kill mythfrontend and restart it. This is really useful especially if you don’t have a keyboard and mouse plugged into your machine all the time or if you just want to make it all wife friendly. Here’s how I did it on my Fedora Core 12 mythtv frontend.

First of all – I’m assuming you already have your remote control working under lircd.

Second of all I used this guide to get me started –> http://www.mythtv.org/wiki/Setting_A_Button_On_Your_Remote_To_Restart_mythfrontend

But I found it didn’t quite work for me, so I modified it a little.

First I created the script similar to the guide above in my mythtv user local bin directory (in my case /home/mythtv/bin/) and called it runmythfrontend.sh

#!/bin/bash
# script to restart mythfrontend
for x in `ps -C mythfrontend | grep -v PID` end; do
test $x != 'mythfrontend' && continue
RUNNING=1;
done
if [ $RUNNING = 1 ]; then
`killall mythfrontend`
else
`mythfrontend &`
fi

Next I created an entry in my .lircrc file to run irexec. irexec is used to run programs when a particular button is pressed on your remote – in my case I wanted the Power button on my remote to run the script above when pressed – this is defined in the .lircrc file and in my case it is stored under /home/mythtv/.lircrc – yours might be somewhere esle depending on your setup. Go here to read more about irexec –> http://www.lirc.org/html/irexec.html

begin
prog = irexec
remote = mceusb
button = Power
config = /home/mythtv/bin/runmythfrontend.sh &
end

Now you need to setup your session to run up irexec when you log in or the server starts up. This is done whilst logged into the user you run mythfrontend as. In my case I have gnome installed so I just go to “System” –> “Perferences” –> “Startup Applications” on the gnome display. You should get something like this (mine is a little cut-off):

Startup Application Perferences

Press “Add” and fill in the name as “irexec” or anything you want really; command as “/usr/local/bin/irexec -d /home/mythtv/.lircrc”; put in a comment if you like or not; then press “Add”. This should now startup irexec when your session starts up.

I suggest you now give your machine a reboot and test it – you might want to check whether your mythbackend is recording anything before you reboot otherwise you will interrupt your recordings. Also if you haven’t already, your might find it easier to setup Fedora to auto login at startup – I’ve written a guide here.

Once rebooted you should be able to press the power button on your remote once to kill mythfrontend and again to start it back up again. That’s it. I welcome comments, feedback and suggestions to make this better or easier.