473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Save Binary data.

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
3 2881
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SOAP | last post by:
how to save binary data to database by using CMP2.0? I would like to save a save image to database through EJB. but I don't know which data type shoud I use. any examples? thanks a lot
7
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: What ist the easiest way to store and save objects in a file generated by a C++ program, by using the "standard C++ library" and/or "Standard Template Library (...
3
by: pfemat | last post by:
Hi there, i am doing some heavy computations whose result i want to save to harddisk. the results are in an long array named screen and i thought of doing char *tmp =...
9
by: danny van elsen | last post by:
hello all, in my application, I want to save an object to a file: what would be the best way to do this? binary or text? self written or existing library? thanks for any answer, Danny.
7
by: Niyazi | last post by:
Hi, I developed an application and I am using SQL Server 2000 developer edition. I create my database and I have also created tbl_USER table. I have an ID, RealName, UserName, and UserPassword...
2
by: mpreisdorf | last post by:
I want to save the raw data of a class (without the .NET object overhead) to a binary file. For example: ref class Test { public: String^ name; Int32 number; ..... }
9
by: linyanhung | last post by:
A int in memory takes 32bits (4 bytes). But if I use ofstream to save a int like this: int i=1234567890; ofstream ofs("c:\\intdata.bin", ios::binary); ofs<<i; It becomes 10 bytes in a...
4
by: Richard Lewis Haggard | last post by:
I have an application that can't use the registry to save various user options and application settings. My first thought was to simply use an application configuration file but this approach seems...
1
by: Chunekit Pong | last post by:
How to save a Base64 encoded string to a binary file For instance, the following XML tag stores the binary data in a Base64 encoded string <data>TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx<data> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.