I have 3000 small sized audio files in my iphone project. File sizes are generally between 1kb and 50kb. I copied all files to one directory and I can play them. To decrease project size what should I do? What about compressing files to a zip file and then unzip on iphone for the first run? Is there any way to combine all of these files and play from one file? What is the ideal solution?
If your files are mp3s, there is little chance that you could make them smaller by compressing them. Indeed, mp3 is a format that allows you to obtain very high compression rates.
What you could do is reducing the encoding, and you could get a substantial gain. E.g., if your files are 256kbps, you could go to 192, or 128... another option that would provide a huge advantage is converting the file to a mono audio file.
I am not saying that all this could be done sensibly for your app, they are just options.
In any case, I would not be too much worried at the 20MB, and you can surely keep all of those files in the resource directory of the app.
Related
I am working a kids app. It has number of video files and png files. All to gather came to size of 1.6GB after compressing. Is there any way to reduce the file size to use in app.
try compress your image resources.
imageOptim is good choice.
some kind of unnecessary resources, you can make it to download. Video always the hard-disk space killer, put it in the server, if you want to display it, request it and download it as cache.
I have two files inside a zip file.
Now, imagine these two files are big... REALLY big... so big that I can't uncompress them into my old, poor, tiny hard disk.
However, they are simple txt files, so the zipped version is quite small.
I need to JOIN the two files into ONE single file.
As they're too big to extract, I need to do this INSIDE the zip.
Is there a way to do this?
Example:
"compressed.zip" contains "part_1.txt" and "part_2.txt".
I want "compressed.zip" to contain one file, called "part_1_and_2.txt".
(If it's not possible with zip, I can pick another compressor... but the idea is the same: each uncompressed file is bigger than total capacity of my hard disk)
Tnx!
It seems like you just need to ensure that the storage requirements are low; I don't think the operation needs to occur "within the zip file" per se. You can do this with command-line tools (in Linux or with similar tools via Cygwin) in the following way:
Start with a tarred, gzipped file with your input files in it. Let that be compressed.tar.gz. Then you can extract the contents of the gzipped tar archive to standard output and pipe it back to gzip:
tar xzf compressed.tar.gz -O | gzip > part_1_and_2.txt.gz
The resultant compressed file is the text of part_1.txt and part_2.txt concatenated (though I suppose it is not the same as having a tar archive that contains one file, but perhaps this will be sufficient).
If you need to do this within a program, I would guess that libtar and zlib can perform this functionality programmatically, or you can run a script from your program.
You can use libzip (which in turn uses zlib) to read uncompressed data from the input files in turn and write a new output zip file. You would not need to store all of an uncompressed file on the mass storage or in memory. You can read and write a small chunk at a time, as you would without compression. I presume that you have room on your mass storage for all three of those zip files.
I have a large PNG that I want uncompressed to a file, but I don't have the memory capacity on the device to expand the PNG in memory, then to a file.
Is there a native iOS method to uncompress a PNG for each scan line? Alternatives?
Libpng - Reading image data - http://www.libpng.org/pub/png/libpng-1.2.5-manual.html#section-3.8
For non-interlaced PNGs
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
As and idea how to start:
Take a look how is doing Java the png decompressing algorithm. Java should have open-source those files. Maybe has the iOS too idk. Just get the uncompress algorithm idea. It should be around 1k-5k lines of code.
When you know how to do it, than implement at iOS but read a chunk of file and than export to a file, read another chunk and process and export it. I know it is easy to say and at least theoretically it is working. Maybe is public in some site. Libpng can be a good starting point.
Png is a looseness compression like zip. There as I have remember runtime is built a data table. Those table depends how big is, maybe need to be swapped to to disk, which will makes longer the decompression process.
Good luck!
I am looking to integrate opening/viewing CBZ/CBR file in iOS6 (A simple viewer like UIWebView that reads PDF file will be fine as well).
Are are there any libraries (Commercial or free) that are available for opening these file types?
Thanks in Advance
CBR files are renamed .rar files and CBZ files are renamed .zip files, so you can look for a solution from there. I've never come across a library file specifically targeted for them, but that might not exclude the possibility of one existing, but as they're just standard compression files renamed to make them more portable between CBR/CBZ readers you should be okay with standard decompression libraries.
The library will spit out a number of image files when the decompression has finished, if you extract one with a standard decompression tool you'll see how they'll be presented.
I am developing app for studying foreign languages, and I'll need to ship 80000 little audio files in my app.
To reduce the size of my app I decided to ship only part of them in the bundle, on the zip archive, and then un-archive it to documents directory. Then, when iPhone will be in Wi-Fi network, I'll little by little download all the others.
But the problem is that Apple says, that we are not allowed to store big files in the Documents Directory. Flagging files for not backing up works only since 5.0.1
So I see two ways for me:
Ship all the files without zipping them and storing them in the app bundle – but that's too huge.
Ship a zip, un-archive it to the cache directory and then check, if they are (not deleted by system), and download one, if it's removed.
What should I choose or is there any other way for me to work it out?
Zipping audio files isn't a good way. I'm sure that saved space will not play any role.
Best solution is to use AAC encoded audiofiles.
Choose suitable quality between 64-128 kbps. And probably mono.
iPhones 3Gs and higher have hardware support for this codec.
There isn't much point in zipping files in the app bundle if you will just decompress them to the documents directory. When app bundles are delivered to iOS devices from the app store they are zipped up anyway (.ipa file), so unzipping to documents will make your app actually take up much more space on the user's device (once in the app bundle and once in the documents directory).
Automated way:
If you want to download them without using too much documents space you can write a predictive cache which has a maximum allowed size. You can keep track of when each file was last accessed and when you need to download a new file remove the oldest-accessed files until you have enough space. Your app can predict which files are needed next based on progression through the lessons, but even if they access a not-present file you can download it just-in-time and add it to the cache for future re-use.
Manual way:
You could provide a user interface to show the user how much space the different lessons are using and split it into lesson packs. Allow the user to control which packs remain cached and show how much space they use. They can decide when to download new packs as they progress through the lessons and when to remove old ones (if they want to save space). If the user wants to keep the files locally then you should let them, even though it uses lots of documents space.