Current focus: EndSoftwarePatents.org: wiki, mailing list, news, donate

Portrait photo of Ciaran

Some commands I like

Menu


But first... My favourite software packages

These are software packages that make my life easier. I use the GNU/Linux operating system, but most or all of these are available for other operating systems too.

Adding Ogg vorbis comments

Here's a command to add a comment to an Ogg Vorbis audio file:

vorbiscomment -a Ciaran_O\'Riordan_-_End_Software_Patents_-_LibrePlanet_2009.ogg -t "comment=Transcript: http://groups.fsf.org/index.php/Ciaran_O'Riordan_(LP09)"

Making oggs directly from CD

Convert track 1 of a CD to ogg via pipe:

cdparanoia 1-1 - | oggenc -q 3 -o track-01.ogg - ; done

And to do that for a CD of 20 tracks:

for i in `seq -w 1 20`; do cdparanoia ${i}-${i} - | oggenc -q 3 -o track-${i}.ogg - ; done

OCR'ing a .pdf or .ps

gs -sPAPERSIZE=a4 -sDEVICE=pnmraw -r300 -dNOPAUSE -dBATCH -sOutputFile=- -q input.pdf | ocrad > output.text

There's an article about a more thorough method here: How To Extract All Text From PDFs (Including Text In Images).

Replacing spaces in filenames with underscores

Here's a command which operates on all .pdf files in the current directory. It replaces any spaces in the filenames with underscores.

find . -maxdepth 1 -iname '*.pdf' | while read n; do mv "$n" `echo "$n" | sed 's/ /_/g'`; done

Reading lists of words from files

I have two files with lists of words, each has one word per line, and I want to run a command based on all combinasions of those two lists. For a practical example, there's a website that posts videos each day, but they don't provide a convenient way to download them. The file names are different each day, but many use a recurring set of words used to form the file names, so if I try all those combinations, I'll get a few videos each day.

cat prefixes | while read p; do cat suffixes | while read s; do wget -c http://videos.gmanews.tv/2010a/03/${p}_030710_${s}.flv; done ; done

In this example, I'll also have to change the date (mmddyy).

Playing audio at increased speeds

To play a file at 1.7 times normal speed with mplayer:

This increases the playback speed without increasing the pitch.

Playing video at increased speeds

To play a video at increased speed, while keeping the audio and video in sync, you have to launch mplayer with the following command, and then use the keys "]", "}", "[", and "{".

If you set the initial speed to something other than 1, the video will be out of sync. If you launch mplayer without the scaletempo option, when you increase the speed you'll change the pitch of the audio.

More info here.

Math on the bash command line

This is a command I used to make a HTML table so I could see what the timestamp on my audio file turns into when I'm listening with the speed increased by 70%. (See mplayer speed commands.)

for i in `seq 1 100`; do echo \<tr\>\<td\>$((${i} / 60)):$((${i} % 60))\</td\>\<td\>$(( $(( $((${i} * 10)) / 17)) / 60)):$(( $(( $((${i} * 10)) / 17)) % 60))\</td\>\</tr\>; done

Playing audio/video at more than 100% volume

If you've audio or video files where the volume is too low, mplayer can amplify them with this command:

mplayer -softvol -softvol-max 1000 file.ogg

When you play the file, the volume will be at the normal (low) level, but by hitting * you can increase the volume to 1000% of the normal maximum. To decrease the volume, hit /.

Run a program in another language

If you want to run, say, GIMP in Spanish, you can lauch it with this command from a shell command line:

LANGUAGE=es_ES gimp

For some commands such as "date", you use "LANG" instead and you can only use the languages of "locales" that are installed on your system. To see the list of locales, type:
locale -a

LANG=nl_BE.utf8 date

And if you want to specify a list of preferences, there's info in the glibc manual. This is for if you want designate, say, Dutch as your primary language, and French as your second language. If you only set one preference, then you'll always get the default (English) when something isn't translated to your preferred language.

Extract audio from a video (mp3 from flv)

Here's the command I used to get the audio from a .flv video:

mplayer rozemarijn.flv -dumpaudio -dumpfile rozemarijn.mp3

When mplayer is given the dumpaudio command, it dumps an exact copy of the audio data that's in the original file. No conversion is done and no data is lost, so you can do this infinitely without degrading the audio. This also means that you don't choose the format of the resulting audio file. In this case, I knew the audio in the .flv file was in the MP3 format, so I gave the output file a name ending in ".mp3". I could have called the output file "rozemarijn.wav" or "rozemarijn.ogg", but that wouldn't change anything. The audio would still be in MP3 format.

Seeing what URLs are being accessed

The following are suggestions for how to see what URLs your computer is accessing. This can be useful, for example, if you can see a video in your browser and you want to download it directly. I haven't gotten to try these commands out yet. They were suggested in a discussion thread on LWN.net (Thanks!).

A forgotten ffmpeg command

Hmm, I don't remember exactly what this does:

ffmpeg -i filename -ab 56 -ar 44100 -b 500 -s 320x240 filename.mpg

It might have something to do with Rockbox's instructions for shrinking videos.

Here's another. It's changes the size to 176x144, discards the audio (-an), uses 15 frames per second and changes the video codec.

avconv -i inputfile.flv -s 176x144 -an -vcodec h263 -ac 1 -ar 8000 -r 15 -ab 32 -y outputfile.3gp

Chopping off black borders in fullscreen video

mplayer -fs -panscan 0.8 name-of-film.ogv

Setting up Apache+MySQL+PHP (on Debian GNU/Linux)

Here's what I did to get the necessary Debian packages working to allow me to install MediaWiki 1.17.0 from source. There's a MediaWiki package in Debian but it was out of date. Further down on this page there's my notes about the installation and setup of MediaWiki itself.

Ok, that's Apache working. PHP next.

That's PHP working.

MySQL didn't require any setup. I set a "root" password, but I think that was optional.

Setting up MediaWiki (with the above software)

With Apache, MySQL, and PHP install (per above), here's what I then did to get MediaWiki 1.17.0.

That was pretty easy. I'm surprised that MySQL required no attention at all.

While looking into caching and performance I found people suggesting the following:

Mplayer gives errors - use alternative backends

I got error messages when reading MP3s with Mplayer. With a 2012 version, the error message was something like:

And when I downgraded to a 2010 version of mplayer, I got a different error:

Each repeated hundreds of times.

The solution seems to be (not tested yet) to tell mplayer to use another backend. mplayer -ac help will show the available backends, and you can use another with the command switch -afm ffmpeg (to use the "ffmp3" codec/backend.


(Go: homepage of Ciarán O'Riordan)

Valid XHTML 1.1! Powered by GNU Made with Emacs Join FSF! (I'm member #8)

(I made the Emacs and GNU buttons. Feel free to do with them whatever you like.)

© Copyright 2013 Ciarán O'Riordan. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. Distribution of modified versions of all or part of this article are permitted, provided that such works carry three things: (1) this copyright notice, (2) prominent notices stating the that it has been changed, and (3) information for how to obtain the original (such as a URL).