Shell script for compressing PDF files on Ubuntu

ubuntu-logo112Back on OSX one of my favourite small programs was called PDFCompress, which compressed a large PDF file into something more manageable. There are many ways of doing this on Ubuntu as well, but nothing really as smooth as I used to on OX.

Finally I took the time to figure out how I could make a small shell script based on ghostscript. The whole script looks like this:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r150 -sOutputFile="compress_$@" "$@"

and by saving it in the nautilus scripts directory:


It shows up when I right click on a file. For most of the files I have tried so far today (uncompressed PDF files), it compresses the files to at least 1/10th of the original size. Very useful, particularly when I only need screen resolution for files.

Screenshot from 2016-06-29 16-55-49

Simple video editing in Ubuntu

I have been using Ubuntu as my main OS for the past year, but have often relied on my old MacBook for doing various things that I haven’t easily figured out how to do in Linux. One of those things is to trim video files non-destructively. This is quite simple to do in QuickTime, although Apple now forces you to save the file with a QuickTime container (.mov) even though there is still only MPEG-4 compression in the file (h.264).

There are numerous linux video editors available, but most of these offer way too many features and hence the need to re-compress the files. But I have found two solutions that work well.

The first one, ffmpeg, should be obvious, although I hadn’t thought that it could also do trimming. However, I often like GUI software, and I have found that Avidemux can do what I need very easily. Just open a file, add start and stop markers for the section to be trimmed, and click save. As opposed to QuickTime, it also allows for saving directly to MPEG-4 files (.mp4) without recoding the file.

There was only one thing that I had to look up, and that was the need for starting the trim section on a keyframe in the video. This is quite obvious when wanting to avoid re-encoding the file, but unfortunately Avidemux doesn’t help in explaining this but only gives an error message. The trick was to use the >> arrows to jump to the next keyframe, and then the file saved nicely.

MultiControl on GitHub

Screenshot of MultiControl v0.6.2
Screenshot of MultiControl v0.6.2

Today I have added MultiControl to my GitHub account. Inititally, I did not intend to release the source code for MultiControl, because it is so old and dirty. The whole patch is based on bpatchers and trying to hide things away in the pre-Max5-days, when presentation view did not exist.

I originally developed the Max patch back in 2004, mainly so that I could distribute a standalone application for my students to use. I have only incrementally updated it to work with newer versions of Max and OSX, but have never really given it a full brush-over.

The reason why I decided to release the code now is because I get so many questions about the program. Even though there are several other good alternatives out there, a lot of people download the application each month, and I get lots of positive feedback from happy users. I also get information about bugs, and occasionally also some feature requests. While I do not really have time to update the patch myself, hopefully someone else might pick it up and improve it.

Happy multicontrolling!

If you did not understand anything about the above, here is a little screencast showcasing some of the functionality of MultiControl:

Dynamic logo at the Norwegian Academy of Music

nmh-frontThe Norwegian Academy of Music launched their new web page and logo today. As part of the visual profile, they wanted to create a dynamic logo, continuously reflecting the activities at the school. I was asked to contribute to making this new dynamic logo dynamic, and we ended up basing the system on analysis of the sound of the school.

The system I have developed is based on microphones in the canteen and the two concert halls. The audio signals from the microphones are fed to an analysis program, which in turn sends three global and perceptual paramaters (sound level, sharpness, and noisiness) to the logo generator running at the web server. The logo generator interprets the three sound parameters, and modifies the shapes, sizes and colours of the graphical elements in the logo.

To the right is a screenshot of how the logo looks on the web page, and below are a couple of examples of different shapes that appear.




The analysis program has been developed in the graphical programming environment Max, using the analyzer~ external for the audio analysis, and some components from the Jamoma library. The most challenging part was to create a solid TCP-connection to the web server, and to secure that the hardware and software can run for many years without interruption. The interface for the application is shown below.




It has been a fun project to work on, particularly as it has required to develop something that will run for much, much longer than anything else I have created previously.

Batch convert RTF files to TXT

Last year I decided to use plain text files (TXT) as the main file type for all my computer text input. There are several reasons for this, but perhaps the most important one was all the problems experienced when trying to open other types of text-based files (RTF, DOC, etc.) on various iOS and Android devices that I use daily. Another reason is to become independent of specific software solutions, forcing you to use a specific software for something as basic as writing text on your computer or device. Along the way I decided to shift my note-taking from MacJournal to nvALT. The best thing about nvALT is that it can unobtrusively monitor a folder of text files, and it allows for quickly searching in old files and write new ones. Since all the files are just plain text files stored in a regular folder (and sync’ed to the cloud), I can of course also use any text editor to view and write the files.

The problem was how to get all my previous notes into my new “system”. I have used a number of different note taking software over the years (e.g. Journler, DevonThink and Evernote). Fortunately, I have been quite careful about exporting all the notes regularly, mainly as RTF files. Having a few thousand such files (and some others), I looked for a solution to quickly convert them to plain text files. There are more complex solutions for converting text files to various formats (e.g. Pandoc), but I found the easiest solution was to use the OSX command line utility textutil. This little line will convert all RTF files in a folder to TXT files:

find . -name \*.rtf -print0 | xargs -0 textutil -convert txt

It will (of course) remove any formatting, but it will preserve all the (text) content nicely.