“Watching someone else use your computer is like watching a drunk orangutan solve a Rubix cube.
- Matthew Inman, The Three Phases of Owning a Computer
Posted December 31st, 2009 - PermalinkI was working on a screen cast for a project and I could not get anything to work the way I wanted to. I didn’t have the desire to purchase software, so I sought a way to annotate it for free. I tried a half dozen free and open source video editors, with no real luck. Either they choked on the format I captured (from CamStudio) or they didn’t have a readily available inline text tool.
What I ended up using was plain old subtitles, plus the handyman’s secret weapon, mplayer/mencoder.
Here’s what I did. I fired up the video in VLC and found the points where I wanted to put my subtitle help text. Subtitle files are usually pretty straight forward. I chose the .srt format, which is plain text. You can edit by hand, or you can use a tool, I used the aptly named subtitleeditor. Which, by the way, barfed on my video file.
Here’s a snippet of the resulting .srt file:
1 00:00:00,000 --> 00:00:13,000 Welcome to the product gallery walk through. 2 00:00:13,000 --> 00:00:23,000 Adding a product: Select image. 3 00:00:23,000 --> 00:00:32,000 Insert title and description.
Next I needed to turn those “soft” subs into “hard” ones. This is where mplayer/mencoder come in. To add soft subs to a video in mplayer, you use the -sub option. Running this in mplayer first is a good way to see how it will look at tweak it according to the many options you have. I went with the defaults, it looks pretty good that way.
Lastly, I needed a good mencoder recipe to pull it all together. After lots of searching I found a great MPEG4 one here.
It’s a two pass system, and the crucial piece is in calculating the bitrate:
bitrate = 50 * 25 * width_of_video * height_of_video / 256
My bitrate was 2540600. After you get that, you just plug it into the two passes below. This includes my subtitle options.
mencoder -o /dev/null -ovc lavc -lavcopts vcodec=msmpeg4v2:vpass=1:vbitrate=2540600:mbd=2:keyint=132:vqblur=1.0:cmp=2:subcmp=2:dia=2:mv0:last_pred=3 -nosound -sub MySubTitles.srt -subfont-text-scale 3 RawScreenCast.avi mencoder -o FinishedScreenCast.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vpass=2:vbitrate=2540600:mbd=2:keyint=132:vqblur=1.0:cmp=2:subcmp=2:dia=2:mv0:last_pred=3 -nosound -sub MySubTitles.srt -subfont-text-scale 3 RawScreenCast.avi
It takes a while but not too long. When all was said and done I had a perfect hard-subbed version and it shrank my file size from ~550MB to 7.6MB. That is a great encoding recipe.

An average frame, with hard subs.
I spend a lot of time on the command line, and one thing I run up against every once in a while is doing math. I normally jump through the bc hoops, but today this bit came through my feed reader.
calc(){ awk "BEGIN{ print $* }" ;}
Just drop it into your .bashrc, .alias, or whatever else you use.
jmhobbs@asuka:~$ calc 9*100+14/10 901.4 jmhobbs@asuka:~$
Great solution using existing tools, props to TinyHacker.com for this one.
Posted November 3rd, 2009 - PermalinkAlthough I am personally switching over to git for my projects, we still use Subversion here at work.
Something I’ve noticed recently is that SVN now stores my passwords in gnome-keyring. This appears to be a feature in version 1.6 and I am running 1.6.5. It seems from that article that it can also use KDE’s Wallet system.
However, I do not use Gnome, and I don’t like KDE wallet. Plus, sometimes it seemed that gnome-keyring would stick on me during a transaction. The only way to fix it was to run another transaction (svn update usually) in another shell.
I finally got sick of it today and Google’d around. Here is the fix I found, edit ~/.subversion/config and add one key.
[auth] password-stores =
Easy enough, and once I did everything was a-okay. Hope this helps someone else!
jmhobbs@katya:/var/www/experimental/source$ svn commit -m "SOME MESSAGE" Password for 'default' GNOME keyring: Sending SOME FILE Transmitting file data ... Committed revision 448. jmhobbs@katya:/var/www/experimental/source$ vim /home/jmhobbs/.subversion/config jmhobbs@katya:/var/www/experimental/source$ svn update Authentication realm: <http://svn.REDACTED.com:80> Private SVN Password for 'jmhobbs': ----------------------------------------------------------------------- ATTENTION! Your password for authentication realm: <http://svn.REDACTED.com:80> Private SVN can only be stored to disk unencrypted! You are advised to configure your system so that Subversion can store passwords encrypted, if possible. See the documentation for details. You can avoid future appearances of this warning by setting the value of the 'store-plaintext-passwords' option to either 'yes' or 'no' in '/home/jmhobbs/.subversion/servers'. ----------------------------------------------------------------------- Store password unencrypted (yes/no)? yes At revision 448. jmhobbs@katya:/var/www/experimental/source$
Wow, long time no post. Darcy and I got a digital camera about a week ago, a Nikon D90. We haven’t really had a chance to put it through it’s paces, but we’ve taken a few pictures around the house to play with it.
At about 3mb each (JPEG’s) the images are really slow to preview in Konqueror. I decided it would be better to be able to download all the photos from the card, then run a script to make my thumbnails. That way I wouldn’t have to wait around while I was viewing photos, instead I could just wait once at the beginning of the process.
My resulting script may have some holes, but it works well for me on Sidux. It takes all of the images in the current directory and makes 600×600 base thumbnails into a directory called “thumb” then uses those to make 12 image contact sheets into a directory called “contact”.
| real | user | sys | |
|---|---|---|---|
| resize | 0m43.478s | 0m40.625s | 0m2.525s |
| scale | 0m25.449s | 0m22.975s | 0m2.236s |
| sample | 0m18.362s | 0m15.983s | 0m2.211s |
| Script times for 16 JPEG images at 3Mb each To 600×600 thumbnails and 200×200 contact sheet frames. |
|||
Your results will vary, but I ran it with three different scaling types (resize, scale, sample). I’m fine with the output from the fastest one (sample) but you can do as you please. I didn’t add command line options because I wanted to have consistent sizes and qualities every time I use it.
Side By Side Resize Method Comparison Click For Fullsize |
Sample Contact Sheet Click For Full Size |
It keeps you updated so you know it hasn’t stalled, here is a sample run.
jmhobbs@asuka:~/Desktop/D90/dcim/example$ digiCamProc.sh Processing 16 Images Creating Thumbnails 100% Creating Contact Sheets 1 of 2 2 of 2 jmhobbs@asuka:~/Desktop/D90/dcim/example$
And here it is. Feel free to comment your changes!
#!/bin/bash # Digital camera thumbnail/contact sheet tool # http://www.velvetcache.org/ # # Copyright (c) 2009 John Hobbs # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitation the rights to use, # copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following # conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. ### SETTINGS ### # Scaling Methods: # resize (Best/Slow) # scale (Middle/Middle) # sample (Worst/Fast) METHOD="sample" # Thumbnail Size THUMBSIZE="600x600" # Thumbnail Directory THUMBDIR="thumb" # Thumbnail Quality THUMBQUALITY="80" # Contact Item Size CONTACTSIZE="200x200" # Contact Sheet Max Width CONTACTWIDTH="3" # Contact Sheet Max Height CONTACTHEIGHT="4" # Horizontal Spacing CONTACTSPACINGH="3" # Vertical Spacing CONTACTSPACINGV="3" # Contact Sheet Directory CONTACTDIR="contact" # Contact Sheet Quality CONTACTQUALITY="100" ################ CONTACTCOUNT=$(($CONTACTWIDTH * $CONTACTHEIGHT)) PIX=$(ls -l *.jpg | wc -l) echo "Processing $PIX Images" echo echo "Creating Thumbnails" mkdir -p $THUMBDIR CTR=0 echo -n "0%" for i in *.jpg; do echo -ne "\r" echo -n "$((100 * $CTR / $PIX))%" convert -strip -quality ${THUMBQUALITY} -${METHOD} ${THUMBSIZE} "$i" "${THUMBDIR}/${i}" CTR=$(($CTR + 1)) done echo -ne "\r" echo "100%" echo echo "Creating Contact Sheets" mkdir -p $CONTACTDIR CTR=0 PAGES=$(($PIX / $CONTACTCOUNT)) if [ $(($PIX % $CONTACTCOUNT)) -ne 0 ]; then PAGES=$(($PAGES + 1)) fi PAGE=1 LIST="" for i in ${THUMBDIR}/*.jpg; do if [ $(($CTR % $CONTACTCOUNT)) -eq 0 ] && [ $CTR -ne 0 ]; then echo "$PAGE of $PAGES" montage -label %f -quality $CONTACTQUALITY -frame 5 -tile ${CONTACTWIDTH}x${CONTACTHEIGHT} -geometry ${CONTACTSIZE}+${CONTACTSPACINGH}+${CONTACTSPACINGV} $LIST jpg:- > ${CONTACTDIR}/${PAGE}.jpg LIST="" PAGE=$(($PAGE + 1)) fi LIST="$LIST $i" CTR=$(($CTR + 1)) done if [ $(($CTR % ${CONTACTCOUNT})) -ne 0 ]; then echo "$PAGE of $PAGES" montage -label %f -quality $CONTACTQUALITY -frame 5 -tile ${CONTACTWIDTH}x${CONTACTHEIGHT} -geometry ${CONTACTSIZE}+${CONTACTSPACINGH}+${CONTACTSPACINGV} $LIST jpg:- > ${CONTACTDIR}/${PAGE}.jpg fi