By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

Save Binary data.

P: n/a
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?
Thank you!
Dave

Aug 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Images are binary data, don't do anything to them just save them
to files on disk in their binary format. The extra processing of
pickling them isn't going to help. Directories with large
numbers of files was a problem in FAT16 and FAT32 filesystems but
not really a problem in NTFS or Linux (at least that I've found).
Appending 100-200 images together into a single file will surely
cut down on the number of files. A lot depends on what the next
step in the process is expecting (e.g. individual files or a
a stream of data). If it is individual files, you will have to
split them back apart anyway so keeping them as individual files
is a benefit.

Larry Bates

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?
Thank you!
Dave

Aug 19 '05 #2

P: n/a
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/
Aug 19 '05 #3

P: n/a
Larry Bates <lb****@syscononline.com> writes:
Directories with large numbers of files was a problem in FAT16 and
FAT32 filesystems but not really a problem in NTFS or Linux (at
least that I've found).


Depends on how you define "large" and what Linux file system you're
using. Of course, if you open the directory in a GUI directory
browser, you're probably going to be unhappy no matter what the
underlying file system.

The standard Unix solution to this is to break the files out into
subdirectories. Create a subdirectory with the name being the first
few letters of the file name, and then store the file in that
subdirectory. Easy to do programmatically, it's still easy to find
files "by hand", and you can make it as fine-grained as you want.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Aug 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.