Save Binary data.

Benjamin Niemann pink at odahoda.de
Fri Aug 19 11:13:14 EDT 2005


GMane Python wrote:

> Hello All.
>   I have a program that downloads 'gigabytes' of Axis NetCam photos per
>   day.
> Right now, I set up the process to put the images into a queue, and every
> 30
> or so seconds, 'pop' them from the queue and save them to disc.   I save
> them as individual files.
> 
>   I think that I'd like to modify it to save into one file 100-200 images,
> so that I don't have directories with 50,000-90,000 frames before handing
> that off to a DivX Encoder.
> 
>   I don't know if I need to use something like cPickle, or maybe just save
> them as a binary data file (which would be a temp file until later in the
> day when I open it to begin the encoding process.)
> 
> Can someone please help me with some direction?

You could use the tarfile module to create a single file holding a arbitrary
number of files - including compression, if you want, but if your images
are JPEGs then further compression is mostly a waste of CPU cycles. You can
extract the images later on with either a python script and tarfile or
using the standard commandline tool 'tar'.

If the images are uncompressed anyway, you could have a look at the netpbm
suite and its fileformat (which is pretty simple, but uncompressed and
would bloat JPEGs to a multiple of the original filesize) which supports
'image sequences'. Perhaps a DivX encoder could even support this
fileformat directly as input.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/



More information about the Python-list mailing list