Friday, 29 April 2011

Adding a PPA in Maverick

Happy day for those ubuntu users who want the video transcoding application Handbrake. I find this useful because it is the only application that will spit out video that an iPhone or iPad will actually play. Anyway, my live cd instructions contained a breathless explanation of how to build handbrake from source. You no longer need to do that. You just need a ppa instead.

OK, what's a PPA? It is like an official ubuntu source of packages, but it is not maintained by canonical. It stands for personal package archive. These are useful for all kinds of things. Here it is used for software not tested by the people who make ubuntu, and which doesn't form part of the ubuntu repositories of packages.

In addition, a useful download manager is also now available for ubuntu in a ppa: jdownloader. What we are about to do is add two ppa's to our list of sources of ubuntu applications, then update our list of what applications are contained in all of our sources, and then we will install the two applications in question.

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo add-apt-repository ppa:jd-team/jdownloader
sudo apt-get update
sudo apt-get install handbrake-gtk jdownloader

Friday, 22 April 2011

Batch flv to mp4 conversion

If you have been happily downloading and storing flash videos you may end up with a whole pile of flv files. My instructions above included a command to convert each file into an mp4 file which is much easier to work with.

What about converting a whole folder full at once?

Try this:

for file in *.flv ; do ffmpeg -i $file -acodec copy -vcodec copy ${file%.flv}.mp4 ; done

That three stage command does the following (in english):

The first bit before the semi colon means, [for] each [*] file that you find in the current folder with the extension [flv], take the full name of the file forward into the next part of the command as a variable [file]. The next bit says that you [do] the command [ffmpeg] using as an [i]nput the variable [$] called [file]. The options for the ffmpeg command are to [copy] the [a]udio [codec] and the [v]ideo codec, so no recompression. You retain the same data but in a different container. The output of the command is a file with a name made up of the variable [$] called [file] minus [%] the characters [.flv] PLUS the characters [.mp4]. The last bit after the second semi colon closes the command sequence started by the [do]. If you felt brave you could stick a [r]e[m]ove command in here to get rid of your input files in before the [; done].

Friday, 15 April 2011

Listening to BBC Radio Shows on an MP3 player

In the name of bastard fuck, this was far fucking harder than it had any right to be.

You have Windows Media Centre installed on your PC. Either XP, or Vista or 7. Whatever. Fine. You record DVB-T1 broadcast TV programs and watch them quite happily. You record the odd radio program (also broadcast over DVB-T1), and you can play it back on the TV. But who wants to sit around the TV listening to radio programs, what do you think this is, the 1930's?

You have recorded an audio file. You want to listen to the audio on another device. How fucking difficult do you think this is going to be? Oh, boy you are in for a fucking treat.

So, how do we do this? I should interject here and say that there is a fairly straightforwards, albeit time-consuming, way to deal with this. You fire up audacity, change the input source to be the sound card audio out, then hit record and play whatever it is you want to record. The problem with this is that you are recording a compressed track so you are going to lose quality. In my view the BBC are the experts when it comes to digital audio compression and trasmission, and it is going to spoil whatever they broadcast if I recompress it. Its like sitting in the back row of the cinema with your digital video camera. You are not exactly going to walk out with a blue ray quality version of the film are you?

First thing. If using Vista or Windows 7, media centre spits out files with the extension .wtv. These are unreadable by anything but windows, so we need to convert them into a more common format. Helpfully if you right click on the file you will find an option to convert it to dvr-ms file.

What I would then ordinarily do is fire the file up in Video Redo. This is an excellent product for taking in a dvr-ms file, cutting out all the bits you do not want (ads and so forth) and then spitting out the original video and audio streams in an mpg file. You can then happily load that mpg file into avidemux, or your editor of choice and convert it to whatever format you desire.

However, Video Redo shits itself when it is given a dvr-ms file without any video. It just cannot handle it. The more recent versions of Video Redo may be different, but I am not paying for an upgrade for something this simple.

So we want to extract the audio in some other fashion. When something is difficult, then make it harder by doing it on the command line. If we want robust command line editing tools then we want Linux. I have tried ffmpeg under ubuntu with a command that looks a bit like this:

ffmpeg -i -acodec copy -o filename.mp2

Doesn't fucking work. Apparently ffmpeg also cannot handle the earth shattering reality of a dvr-ms file without a fucking video stream.

How about:

mplayer -dumpaudio -dumpfile audio.mp2

No fucking joy. Cannot ever find an audio stream. It turns out that vlc is practically the only fucking thing on the planet that will spit the untouched audio out of a BBC Digital TV Broadcast Radio Recording. The command is this gem:

cvlc "[filename].dvr-ms" vlc://quit --sout '#transcode{vcodec=none}:duplicate{dst=std{access=file,mux=raw,dst="[filename].mp2"}}'

That's a fucking little beauty isn't it. Far more than you could ever realistically want to know about those options can be found here and here.

Friday, 8 April 2011

How to Post Maths in Blogspot: MathJax & QuickLatex

Edit your template and add the following before the closing "head" tag:

<script type=\"text/x-mathjax-config\">
  MMLorHTML: {
    prefer: {Firefox: \"HTML\"}
<script type=\"text/javascript\" src=\"\"></script>

Then you just stick the TeX stuff in backslash square brackets for standalone formulae or backslash rounded brackets for in text symbols.

To get graphics you need to use Quicklatex. You need to drop down the choose options box on that page and then insert this text to activate the Tikz graphics package, with the tikz library that lets you calculate co-ordinates using algebra:


You then get the URL of an image which you can stick in your blog.

Friday, 1 April 2011

Can I Exchange this for something that works?

OK, so they you are running Ubuntu on your work PC. You can connect to the office Exchange server using Evolution so you can get all your email. You are doing all of this using open source software. You are most likely feeling pretty smug.

Eventually you will want to leave the office, so you want to fire on the out of office notifications in Evolution. You read about how to do so. You find out you need to follow this chain of menus and buttons:

Edit -> Preferences -> Edit -> Account Editor -> Exchange Settings -> I am out of the office.

However, at the second "Edit" you get a "Evolution Error" window informing you that the lovely open source program you were oh so smug about "could not read out-of-office state"

Bastard. The problem is that if you google for help on this error, the search terms "state" and "evolution" tend to pollute the results with results about the particular subset of Americans who could politely be called reality-challenged. They could also impolitely be described as the type of fucking cretins who would happily watch their friends and family combusting in agonising pain if their sacred text of choice said that humans were impervious to fire.

Even searching in the Ubuntu Forums, I cannot find an answer to this. Or, come to it, why even though I have selected Global Contact List for Auto Completion in the settings, it doesn't fucking auto complete email addresses from the Global Contacts List.