It can be obtained here as an XML file for Zope. WARNING: THE VERSION HERE WILL NOT WORK IF YOUR ZOPE IS BEHIND AN APACHE SERVER ON A DIFFERENT MACHINE. I fixed the software to handle this case, but have not prepared a xml archive yet. [ Nov. 2007]
These are shell incantations for transcoding video with ffmpeg, especially for the ipod or iphone. ffmpeg is one of several free open source video editing programs you can use. These recipes are here partly to make it easier for other people to find them, and partly for me to find them again.
The standard open-source programs for transforming video are ffmpeg and mencoder. Each is capable from reading video in many different files formats, and writing out video using many different video encoding options. Each is supported in some form on Mac OS X, Linux and probably Windows. Both use common source libraries. You can get ffmpeg at http://www.mplayerhq.hu/design7/dload.html in many forms, or else compiled for Win32 at http://sourceforge.net /project/showfiles.php? group_id=205275.
mencoder has more filters than ffmpeg for processing the video. ffmpeg supports more different input and output formats, including direct output to mp4 container files. mencoder support for non-avi files is new and questionable, so for use with Quicktime you need to post-process with mp4creator: that's too much hassle for me, but instructions can be found at: mplayerhq.
My preferred solution is simply to use ffmpeg.
Basic command for iphone-compatible video
ffmpeg -i input-file -f mp4 -vcodec mpeg4 -maxrate 1000 -b 700
-bufsize 4096 -g 300 -acodec aac -ab 192 -s 480x320 output-file
iphone (better setting than above)
ffmpeg -i "$INFILE" -f mp4 -vcodec mpeg4 -maxrate 1000 -b 700 -qmin 3 -qmax 5
-bufsize 4096 -g 300 -acodec aac -ab 192 -s 480x320 -aspect 4:3 "$OUTFILE"
This should be fine with any ipod-like device, but it is customized for the iPhone screen size. The -s 480x320 refers to the size of the iPhone screen; customization for the video iPod would use the same incantation, but with a screen size of 320x240 to produce slightly smaller files. On the other hand, showing the video on TV would benefit from the larger size, or even 640x480. The Apple TV uses as much as 1280x720. (It is never worth using a larger size than your input footage, however, which is often limited to 640x480 for NTSC.) Thus, for the ipod video is might be:
ffmpeg -i "$INFILE" -f mp4 -vcodec mpeg4 -maxrate 1000 -b 700 -qmin 3 -qmax 5
-bufsize 4096 -g 300 -acodec aac -ab 192 -s 320x240 -aspect 4:3 "$OUTFILE"
Other more exotic settings are the following:
sample separate image frames to jpeg images
ffmpeg -i "$INFILE" -y -ss 5 -an -sameq -f image2 -r 1/4 frame%03d.jpg
remove logo(from) from commercial video with lavc mpeg4 codec, avi container
mencoder -vf "delogo=545:401:100:45" -ovc lavc -lavcopts vcodec=mpeg4:acodec=libfaac 002.mpg -o 002.avi
Contrast enhancement (not recommended, can confuse compression)
mencoder -ovc lavc -lavcopts vcodec=mpeg4:acodec=libfaac -vf pp=autolevels:f 002.mpg -o 002.avi
WARNING: note that the -i inputfile flag needs to come early otherwise the resize (resizing/rescaling) flag -s will not have any effect. This is incredibly stupid, yes. At one point I found it didn't work and it took me a long time to figure out the problem that caused my resize to fail.
If you want to play with these, a quick guide to the key (somewhat obscure) ffmpeg parameters are as follows:
`-title string' Set the title. `-b bitrate' Set the video bitrate in bit/s (default = 200 kb/s). `-ss position' Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported. -r fps Set to frame rate `-s size' Set frame size. The format is `wxh' (ffserver default = 160x128, ffmpeg default = same as source). A few of the many allowed appreciations are: `qqvga' 160x120 `qvga' 320x240 `vga' 640x480 `-maxrate bitrate' Set max video bitrate (in bit/s). `-minrate bitrate' Set min video bitrate (in bit/s). `-ar freq' Set the audio sampling frequency (default = 44100 Hz). `-ab bitrate' Set the audio bitrate in bit/s (default = 64k). `-ac channels' Set the number of audio channels (default = 1). `-an' Disable audio recording. `-acodec codec' Force audio codec to codec. Use the copy special value to specify that the raw codec data must be copied as is.
I recently configured a Linux (Ubuntu) web server for SSL support. I had not done this for a long time, and had largely forgotten how. Here is the recipe and a fix to this problem.
Prologue: making your own SSL certificates
The easy solution to generating self-signed certificates needed for SSL is the the CA.pl perl script, which is included in the openssl installation tar ball. You can find it at
or else Google for "openssl-0.9.8 tar gz".
You need to generate suitable security keys (certificates) before you can use SSL. This can be accomplished using these steps from a suitable configuration directory:
perl CA.pl -newca
perl CA.pl -newreq
perl CA.pl -sign
You will have to answer various questions. The questions are stored locally, so the actual answers do not matter much, except for the domain name.
In particular, you should enter your server host name (e.g. www.dudek.org) when asked for a "common name".
This should produce the files newcert.pem and newkey.pem in the current directory.
Setting up Apache to use SSL
The apache2 configuration section for SSL then needs to use these keys with lines like:
Whoops: error -12227
After this I was getting the error in my log file
OpenSSL: Exit: error in SSLv3 read client certificate B
which leads to an error -12227 from Firefox when the site is accessed.
After searching Google I found other people complaining about this, but with no actual diagnosis. Well, I have the answer. Looking at the error logs, I found that it was due to having configured apache/ssl for client authentication without having provided suitable certificates (the detailed story is that apache needs to understand you are acting as your own certificate authority, and not depending on an external one).
Solution to error: SSLCACertificate
The fix is to change the line in the apache config file that reads:
to instead read
After that, it should all work.
CA.pl manual page: http://www.openssl.org/docs/apps/CA.pl.html
SSL configuration explanation:
Ubuntu instructions (good) which avoids using CA.pl:
More user's stories:
Python includes a uudecode and uuencode module (accessible via "import uu"), but the module only supports base32 uudecoding, and not base64. I needed base64. Although I have posted an official patch to the python2.4 library, python had already moved on to a later version. Here is my patch for python2.5 uu.py to make it able to decode and intrepret base64 data. Encoding in base64 is probably pretty easy too, but I don't need it and have not bothers. I encourage somebody to add it.
One problem in applying this patch, especially from a web page, is that the white space versus tabs might not match. The - l flag (that's a lower case L) tells patch to ignore white space, but since python is senseitve to white space, you might have to adjust things manually.
Also note that on OS X, the uu.py module can be found at
The patch file (input for patch -l) is as follows:
--- uu.py.orig 2007-08-25 23:42:35.000000000 -0400
+++ uu.py 2007-08-26 11:42:54.000000000 -0400
@@ -18,6 +18,9 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# Modified by Gregory Dudek, April 2008:
+# - added support for decoding of base64 uuencoded files.
# Modified by Jack Jansen, CWI, July 1995:
# - Use binascii module to do the actual line-by-line conversion
# between ascii and binary. This results in a 1000-fold speedup. The C
@@ -81,7 +84,7 @@
-def decode(in_file, out_file=None, mode=None, quiet=0):
+def decode(in_file, out_file=None, mode=None, quiet=0, base64=0):
"""Decode uuencoded file"""
# Open the input file, if needed.
@@ -100,9 +103,10 @@
if hdr[:5] != 'begin':
hdrfields = hdr.split(" ", 2)
- if len(hdrfields) == 3 and hdrfields == 'begin':
+ if len(hdrfields) == 3 and (hdrfields == 'begin' or hdrfields == 'begin-base64'):
+ if hdrfields == 'begin-base64': base64=1
@@ -130,11 +134,13 @@
s = in_file.readline()
while s and s.strip() != 'end':
- data = binascii.a2b_uu(s)
+ if base64: data = binascii.a2b_base64(s)
+ else: data = binascii.a2b_uu(s)
except binascii.Error, v:
# Workaround for broken uuencoders by /Fredrik Lundh
nbytes = (((ord(s)-32) & 63) * 4 + 5) / 3
- data = binascii.a2b_uu(s[:nbytes])
+ if base64: data = binascii.a2b_base64(s[:nbytes])
+ else: data = binascii.a2b_uu(s[:nbytes])
if not quiet:
sys.stderr.write("Warning: %s\n" % str(v))
My iPhone has been syncing to the wrong calendar in iCal. Here is a simple procedure for merging two calendars together using iCal on OS X. This allows you delete one of the calendars after combining it with another.
1) Use the Export option in the File menu to export the calendar (A) data from the calendar that is to be removed. Export to a file.
2) Select the calendar (B) into which you want to merge the data.
3) Use the Import menu to import the file saved in step 1. This should bring all the events from the calendar A into calendar B.
3.5) Verify that the events in the to-be-deleted calendar is now appearing twice (once for each of the two calendars (A and B) it is now in).
4) Delete the now-redundant calendar B.
I was using the zope server to generate barcode images using PIL, and
found one of my PIL methods was throwing a python error when used in Zope (from an external method), but not otherwise.
The error is a follows:
Error Type: AttributeError
Error Value: 'module' object has no attribute '_save'
The reason for this is that JpegImagePlugin.py
called a module called ImageFile from the PIL library, but Zope also defined a (different) module called ImageFile. Argh!!
Fixing this (for me) involved going into JpegImagePlugin.py
and replacing the line "import ImageFile"
with "from PIL import ImageFile".
A quick fix that took a very long time to track down. This solution is provided here to help the next hapless soul who tries Googling for this error like I did. Now there is at least one solution out here, instead of just queries.
You can see the fixed method in action at
to generate you own code, where the number after the s needs to be 12 digits for an EAN-13 barcode (the 13th checksum digit is computed automatically if not provided).