I have A LOT of (optional) audio files.. I have 6400 audio files, with average size ~40 kb each, and total size ~400 mb..
I was wondering how will I download the files, Is it better to:
download a .zip file and then extract .. less bandwidth , more sdcard space requireed , more cpu to unzip..
download all the files (no .zip file)... more bandwidth , less sdcard and less cpu..
What is more reasonable?
Do a little test first...
Most audio files are already compressed, and Zipping them does not always reduce the size.
And if you can get only a small reduction with a high compression (= high CPU demand) setting then zipping will not be worth it.
You will have to measure to see on what side of the tipping point your files are.
Zipping should you give you a much faster download, as a single connection for download will be faster than openning 6400 HTTP request. (for small files, the time it takes to download is lower than the time it takes to open the connection. But the connection opening is constant, so for a large file you'll have much less time spend on opening connections.)
However, and that's the big point, most users won't be able to download 400MB easily without the network connection dropping. I'd suggest a middle way. Package the audio files into chunks or say 64 files each, (best in directories for faster access and reference) and download 64 files in a single zip or tar for that matter. I'd go with a non-compressing format, as the zipping won't give you much size reduction.
That way, you won't have to worry much about the download failing, and you'll have easy progress tracking.
However, i'd think about if you really need that many files in the first place.
Look if you either just have one biger mp3 file in which you can just play certain areas (just skipping inside the file) when you need it.
I'd also give a thought to lazy loading, just load the files when you need them
There's no need to compress etc .mp3 .flac .ogg but if it's for example a wave file you can compress the size pretty much.
Related
I am thinking of making a download manager for Android.One of the functionality I want is to Download a file in small chunks on different threads for increasing download speed.I want to know how can this increase download speed and in how many parts to divide the file in.
I'm creating simple game in unity and recently I bought some audio clips on assetstore. Some of them are quite big so i searched about import settings for audio and found this. My problem is that I'm building game for android and I don't know which things(like CPU or RAM) are more important for optimization (for android). Do you have any Idea what should I do?
There is no universal rule for choosing Load Type. The catch is that all the sounds need to get decompressed at some point to get played. Compressed 3 megabyte .mp3 file can become 32mb or more. Set Compression Format on PCM and you'll see how much space will it take when decompressed. See Imported Size on this image:
On this image I'm working with .mp3 file which grows from 0.6mb to 7mb on decompression.
Note: this was just a showcase. In fact if you set your Compression Format to PCM the sound will get decompressed on compile-time and Load Type is useless in this case (Unity really should gray it out in this case). But decompressed audio will make the game size bigger.
So, in absolute majority of cases Compression Format is applied (currently only option is Vorbis, Unity may add some more though). Assuming you use compression you should consider if you are willing to sacrifice RAM to get better performance or other way around.
Back to Load Type: For example, if I was to ship my 0.6mb mp3 file to iOS/Android game I would probably set it on Decompress On Load because frame-rate is #1 priority on mobile. I'd need to save CPU cycles during gameplay so I'd try to load sound in menu. But if this was a PC game I'd probably use Compressed In Memory so that it gets decompressed chunk by chunk while playing.
So basically this setting is really for a post-production/optimization. If you're getting Did Receive Memory Warning's a lot than you'd go for Compressed In Memory. But if you're struggling for maintaining a decent FPS than you'd rather set it on Decompress On Load.
I'm curious if someone can point me to (or just describe) how, given that an Android application has an extremely limited memory space to play with (I think it's around 20 megs), a video player can load and play videos that are an order of magnitude or more larger in size. Is the app loading the video in some sort of chunks?
I ask because I have an app that has some video assets embedded and the app has grown to be about 80 megs and is just a total monster for compiling and debugging (without the assets the app would only be about 2 megs), and I was thinking that I should just remove the assets and have them download on the side and sit on the sdcard, rather than within the apk, but I'm worried that loading them and playing them at run time will bust through the app's memory allotment, and was hoping someone can shed some light on what my options are.
TIA
They buffer the video in manageable chunks, yes. Even if your videos are GBs in size, you won't hit a memory wall using standard video playing APIs. You can use the standard calls to setVideoURI or setVideoPath to point to the file and it will handle it from there. The same works for MediaPlayer in general if you're not using a VideoView
Downloading the videos outside the apk is still a good idea, though. If I had to download a new 80MB file for each incremental upgrade, I'd probably just uninstall instead. If you don't want to host them yourself, look into the supplemental apk option.
You can take your game into the native layer where you can bypass this limit. Take a look at a blog I wrote http://jnispot.blogspot.com/2012/10/jnindk-arrays-bitmaps-and-games-oh-my.html
I have no idea if this is what video apps do, but you can actually increase the memory beyond the normal limit by using malloc statements in native code. This bypasses the normal max of around 20 MB.
I have only used this for encryption on android devices where AES encryption needs rather karger amounts of memory when dealing with large encrypted files (even around 10MB files).
I have used AsyncTask for Downloading list of files from server.
At a time only one file is downloaded and after completion of one file another download starts. But downloading of file makes my application to use large amount of CPU more than 30% to 50% and also more amount of RAM.
Please help how to resolve this problem. Can we do any customization so that it use less amount of CPU
i have a weird thing when downloading file from an URL in my program.
I perform check of available updates of files on server by checking same file's size on the device and on the server. When i use getContentLength method of URLConnection class i get one size, then i download and check the downloaded size by bytes which get downloaded and get same size. But when i look at the size of the files on the SDCard they are about 1.4 times bigger. Why does this happen?
So, basically i download one size and get different on SDCard and thats why i can't check if they are updated by asking the server.
URL is of https type, files are .ics
It's possible that it's due to filesystem overhead. I assume you're writing to a FAT32 SD card, in which case there may be significant overhead in some cases.
According to Wikipedia (http://en.wikipedia.org/wiki/File_Allocation_Table):
"Note however, that files are allocated in units of clusters, so if a 1 kB file resides in a 32 kB cluster, 31 kB are wasted."
Consider trying with large files or files of different sizes if possible, and see if the ratio of expected to actual size remains the same.
Solved. The problem was with the encoding. I had to use OutputStreamWriter with secon parameter "UTF8". And that aswell solved the problem with cyrylic letters in the text.